!(function (e, t) {
    'object' == typeof exports && 'undefined' != typeof module
        ? (module.exports = t())
        : 'function' == typeof define && define.amd
        ? define(t)
        : ((e =
              'undefined' != typeof globalThis
                  ? globalThis
                  : e || self).jessibuca = t());
})(this, function () {
    'use strict';
    const e = 0,
        t = 1,
        i = 'flv',
        o = 'm7s',
        r = {
            videoBuffer: 1e3,
            isResize: !0,
            isFullResize: !1,
            isFlv: !1,
            debug: !1,
            hotKey: !1,
            loadingTimeout: 10,
            heartTimeout: 10,
            timeout: 10,
            supportDblclickFullscreen: !1,
            showBandwidth: !1,
            keepScreenOn: !1,
            isNotMute: !1,
            hasAudio: !0,
            hasVideo: !0,
            operateBtns: {
                fullscreen: !1,
                screenshot: !1,
                play: !1,
                audio: !1,
                record: !1,
            },
            hasControl: !1,
            loadingText: '',
            background: '',
            decoder: 'decoder.js',
            url: '',
            rotate: 0,
            forceNoOffscreen: !0,
            hiddenAutoPause: !1,
            protocol: t,
            demuxType: i,
            useWCS: !1,
            useMSE: !1,
            useOffscreen: !1,
            autoWasm: !1,
            heartTimeoutReplay: !1,
            wasmDecodeErrorReplay: !1,
        },
        A = 'init',
        s = 'initVideo',
        n = 'render',
        a = 'playAudio',
        d = 'initAudio',
        c = 'audioCode',
        l = 'videoCode',
        u = 'wasmError',
        h = 'Invalid NAL unit size',
        p = 1,
        m = 2,
        g = 8,
        f = 9,
        b = 'init',
        y = 'decode',
        v = 'audioDecode',
        w = 'close',
        S = 'updateConfig',
        E = {
            fullscreen: 'fullscreen$2',
            webFullscreen: 'webFullscreen',
            decoderWorkerInit: 'decoderWorkerInit',
            play: 'play',
            playing: 'playing',
            pause: 'pause',
            mute: 'mute',
            load: 'load',
            loading: 'loading',
            videoInfo: 'videoInfo',
            timeUpdate: 'timeUpdate',
            audioInfo: 'audioInfo',
            log: 'log',
            error: 'error',
            kBps: 'kBps',
            timeout: 'timeout',
            delayTimeout: 'delayTimeout',
            loadingTimeout: 'loadingTimeout',
            stats: 'stats',
            performance: 'performance',
            record: 'record',
            recording: 'recording',
            recordingTimestamp: 'recordingTimestamp',
            recordStart: 'recordStart',
            recordEnd: 'recordEnd',
            recordCreateError: 'recordCreateError',
            buffer: 'buffer',
            videoFrame: 'videoFrame',
            start: 'start',
            metadata: 'metadata',
            resize: 'resize',
            streamEnd: 'streamEnd',
            streamSuccess: 'streamSuccess',
            streamMessage: 'streamMessage',
            streamError: 'streamError',
            volumechange: 'volumechange',
            destroy: 'destroy',
            mseSourceOpen: 'mseSourceOpen',
            mseSourceClose: 'mseSourceClose',
            mseSourceBufferError: 'mseSourceBufferError',
            mseSourceBufferBusy: 'mseSourceBufferBusy',
            videoWaiting: 'videoWaiting',
            videoTimeUpdate: 'videoTimeUpdate',
            videoSyncAudio: 'videoSyncAudio',
            playToRenderTimes: 'playToRenderTimes',
        },
        B = {
            load: E.load,
            timeUpdate: E.timeUpdate,
            videoInfo: E.videoInfo,
            audioInfo: E.audioInfo,
            error: E.error,
            kBps: E.kBps,
            log: E.log,
            start: E.start,
            timeout: E.timeout,
            loadingTimeout: E.loadingTimeout,
            delayTimeout: E.delayTimeout,
            fullscreen: 'fullscreen',
            play: E.play,
            pause: E.pause,
            mute: E.mute,
            stats: E.stats,
            performance: E.performance,
            recordingTimestamp: E.recordingTimestamp,
            recordStart: E.recordStart,
            recordEnd: E.recordEnd,
            playToRenderTimes: E.playToRenderTimes,
        },
        C = {
            playError: 'playIsNotPauseOrUrlIsNull',
            fetchError: 'fetchError',
            websocketError: 'websocketError',
            webcodecsH265NotSupport: 'webcodecsH265NotSupport',
            mediaSourceH265NotSupport: 'mediaSourceH265NotSupport',
            wasmDecodeError: 'wasmDecodeError',
        },
        R = 'notConnect',
        k = 'open',
        T = 'close',
        I = 'error',
        D = { download: 'download', base64: 'base64', blob: 'blob' },
        x = { 7: 'H264(AVC)', 12: 'H265(HEVC)' },
        L = 7,
        j = 12,
        U = { 10: 'AAC', 7: 'ALAW', 8: 'MULAW' },
        F = 32,
        V = 33,
        O = 34,
        M = 0,
        Q = 1,
        W = 2,
        G = 'mp4',
        J = 'webm',
        N = 'webcodecs',
        P = 'webgl',
        z = 'offscreen',
        Y = 'key',
        H = 'delta',
        X = 'video/mp4; codecs="avc1.64002A"',
        Z = 'ended',
        q = 'open',
        K = 'closed',
        _ = 1e3,
        $ = 27,
        ee = 38,
        te = 40;
    class ie {
        constructor(e) {
            (this.log = function (t) {
                if (e._opt.debug) {
                    for (
                        var i = arguments.length,
                            o = new Array(i > 1 ? i - 1 : 0),
                            r = 1;
                        r < i;
                        r++
                    )
                        o[r - 1] = arguments[r];
                    console.log(`Jessibuca: [${t}]`, ...o);
                }
            }),
                (this.warn = function (t) {
                    if (e._opt.debug) {
                        for (
                            var i = arguments.length,
                                o = new Array(i > 1 ? i - 1 : 0),
                                r = 1;
                            r < i;
                            r++
                        )
                            o[r - 1] = arguments[r];
                        console.warn(`Jessibuca: [${t}]`, ...o);
                    }
                }),
                (this.error = function (t) {
                    if (e._opt.debug) {
                        for (
                            var i = arguments.length,
                                o = new Array(i > 1 ? i - 1 : 0),
                                r = 1;
                            r < i;
                            r++
                        )
                            o[r - 1] = arguments[r];
                        console.error(`Jessibuca: [${t}]`, ...o);
                    }
                });
        }
    }
    class oe {
        constructor(e) {
            (this.destroys = []),
                (this.proxy = this.proxy.bind(this)),
                (this.master = e);
        }
        proxy(e, t, i) {
            let o =
                arguments.length > 3 && void 0 !== arguments[3]
                    ? arguments[3]
                    : {};
            if (!e) return;
            if (Array.isArray(t)) return t.map((t) => this.proxy(e, t, i, o));
            e.addEventListener(t, i, o);
            const r = () => e.removeEventListener(t, i, o);
            return this.destroys.push(r), r;
        }
        destroy() {
            this.master.debug.log('Events', 'destroy'),
                this.destroys.forEach((e) => e());
        }
    }
    var re =
        'undefined' != typeof globalThis
            ? globalThis
            : 'undefined' != typeof window
            ? window
            : 'undefined' != typeof global
            ? global
            : 'undefined' != typeof self
            ? self
            : {};
    function Ae(e, t) {
        return e((t = { exports: {} }), t.exports), t.exports;
    }
    var se = Ae(function (e) {
        !(function () {
            var t =
                    'undefined' != typeof window && void 0 !== window.document
                        ? window.document
                        : {},
                i = e.exports,
                o = (function () {
                    for (
                        var e,
                            i = [
                                [
                                    'requestFullscreen',
                                    'exitFullscreen',
                                    'fullscreenElement',
                                    'fullscreenEnabled',
                                    'fullscreenchange',
                                    'fullscreenerror',
                                ],
                                [
                                    'webkitRequestFullscreen',
                                    'webkitExitFullscreen',
                                    'webkitFullscreenElement',
                                    'webkitFullscreenEnabled',
                                    'webkitfullscreenchange',
                                    'webkitfullscreenerror',
                                ],
                                [
                                    'webkitRequestFullScreen',
                                    'webkitCancelFullScreen',
                                    'webkitCurrentFullScreenElement',
                                    'webkitCancelFullScreen',
                                    'webkitfullscreenchange',
                                    'webkitfullscreenerror',
                                ],
                                [
                                    'mozRequestFullScreen',
                                    'mozCancelFullScreen',
                                    'mozFullScreenElement',
                                    'mozFullScreenEnabled',
                                    'mozfullscreenchange',
                                    'mozfullscreenerror',
                                ],
                                [
                                    'msRequestFullscreen',
                                    'msExitFullscreen',
                                    'msFullscreenElement',
                                    'msFullscreenEnabled',
                                    'MSFullscreenChange',
                                    'MSFullscreenError',
                                ],
                            ],
                            o = 0,
                            r = i.length,
                            A = {};
                        o < r;
                        o++
                    )
                        if ((e = i[o]) && e[1] in t) {
                            for (o = 0; o < e.length; o++) A[i[0][o]] = e[o];
                            return A;
                        }
                    return !1;
                })(),
                r = { change: o.fullscreenchange, error: o.fullscreenerror },
                A = {
                    request: function (e, i) {
                        return new Promise(
                            function (r, A) {
                                var s = function () {
                                    this.off('change', s), r();
                                }.bind(this);
                                this.on('change', s);
                                var n = (e = e || t.documentElement)[
                                    o.requestFullscreen
                                ](i);
                                n instanceof Promise && n.then(s).catch(A);
                            }.bind(this)
                        );
                    },
                    exit: function () {
                        return new Promise(
                            function (e, i) {
                                if (this.isFullscreen) {
                                    var r = function () {
                                        this.off('change', r), e();
                                    }.bind(this);
                                    this.on('change', r);
                                    var A = t[o.exitFullscreen]();
                                    A instanceof Promise && A.then(r).catch(i);
                                } else e();
                            }.bind(this)
                        );
                    },
                    toggle: function (e, t) {
                        return this.isFullscreen
                            ? this.exit()
                            : this.request(e, t);
                    },
                    onchange: function (e) {
                        this.on('change', e);
                    },
                    onerror: function (e) {
                        this.on('error', e);
                    },
                    on: function (e, i) {
                        var o = r[e];
                        o && t.addEventListener(o, i, !1);
                    },
                    off: function (e, i) {
                        var o = r[e];
                        o && t.removeEventListener(o, i, !1);
                    },
                    raw: o,
                };
            o
                ? (Object.defineProperties(A, {
                      isFullscreen: {
                          get: function () {
                              return Boolean(t[o.fullscreenElement]);
                          },
                      },
                      element: {
                          enumerable: !0,
                          get: function () {
                              return t[o.fullscreenElement];
                          },
                      },
                      isEnabled: {
                          enumerable: !0,
                          get: function () {
                              return Boolean(t[o.fullscreenEnabled]);
                          },
                      },
                  }),
                  i ? (e.exports = A) : (window.screenfull = A))
                : i
                ? (e.exports = { isEnabled: !1 })
                : (window.screenfull = { isEnabled: !1 });
        })();
    });
    function ne() {}
    function ae() {
        let e =
            arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : '';
        const t = e.split(','),
            i = atob(t[1]),
            o = t[0].replace('data:', '').replace(';base64', '');
        let r = i.length,
            A = new Uint8Array(r);
        for (; r--; ) A[r] = i.charCodeAt(r);
        return new File([A], 'file', { type: o });
    }
    function de(e, t) {
        const i = document.createElement('a');
        (i.download = t),
            (i.href = URL.createObjectURL(e)),
            i.click(),
            setTimeout(
                () => {
                    URL.revokeObjectURL(e);
                },
                ge() ? 1e3 : 0
            );
    }
    function ce() {
        return new Date().getTime();
    }
    function le(e, t, i) {
        return Math.max(Math.min(e, Math.max(t, i)), Math.min(t, i));
    }
    function ue(e, t, i) {
        if (e)
            return (
                'object' == typeof t &&
                    Object.keys(t).forEach((i) => {
                        ue(e, i, t[i]);
                    }),
                (e.style[t] = i),
                e
            );
    }
    function he(e, t) {
        let i =
            !(arguments.length > 2 && void 0 !== arguments[2]) || arguments[2];
        if (!e) return 0;
        const o = getComputedStyle(e, null).getPropertyValue(t);
        return i ? parseFloat(o) : o;
    }
    function pe() {
        return performance && 'function' == typeof performance.now
            ? performance.now()
            : Date.now();
    }
    function me(e) {
        let t = 0,
            i = pe();
        return (o) => {
            t += o;
            const r = pe(),
                A = r - i;
            A >= 1e3 && (e((t / A) * 1e3), (i = r), (t = 0));
        };
    }
    function ge() {
        const e = window.navigator.userAgent.toLowerCase();
        return e && /iphone|ipad|ipod|ios/.test(e);
    }
    function fe(e) {
        if (null == e || '' === e) return '0 KB/S';
        let t = parseFloat(e);
        return (t = t.toFixed(2)), t + 'KB/S';
    }
    function be(e) {
        return null == e;
    }
    function ye(e) {
        return !be(e);
    }
    se.isEnabled,
        (() => {
            try {
                if (
                    'object' == typeof WebAssembly &&
                    'function' == typeof WebAssembly.instantiate
                ) {
                    const e = new WebAssembly.Module(
                        Uint8Array.of(0, 97, 115, 109, 1, 0, 0, 0)
                    );
                    if (e instanceof WebAssembly.Module)
                        return (
                            new WebAssembly.Instance(e) instanceof
                            WebAssembly.Instance
                        );
                }
            } catch (e) {}
        })();
    class ve {
        on(e, t, i) {
            const o = this.e || (this.e = {});
            return (o[e] || (o[e] = [])).push({ fn: t, ctx: i }), this;
        }
        once(e, t, i) {
            const o = this;
            function r() {
                o.off(e, r);
                for (
                    var A = arguments.length, s = new Array(A), n = 0;
                    n < A;
                    n++
                )
                    s[n] = arguments[n];
                t.apply(i, s);
            }
            return (r._ = t), this.on(e, r, i);
        }
        emit(e) {
            const t = ((this.e || (this.e = {}))[e] || []).slice();
            for (
                var i = arguments.length,
                    o = new Array(i > 1 ? i - 1 : 0),
                    r = 1;
                r < i;
                r++
            )
                o[r - 1] = arguments[r];
            for (let e = 0; e < t.length; e += 1) t[e].fn.apply(t[e].ctx, o);
            return this;
        }
        off(e, t) {
            const i = this.e || (this.e = {});
            if (!e)
                return (
                    Object.keys(i).forEach((e) => {
                        delete i[e];
                    }),
                    void delete this.e
                );
            const o = i[e],
                r = [];
            if (o && t)
                for (let e = 0, i = o.length; e < i; e += 1)
                    o[e].fn !== t && o[e].fn._ !== t && r.push(o[e]);
            return r.length ? (i[e] = r) : delete i[e], this;
        }
    }
    class we extends ve {
        constructor() {
            super(), (this.init = !1);
        }
        updateVideoInfo(e) {
            e.encTypeCode && (this.videoInfo.encType = x[e.encTypeCode]),
                e.width && (this.videoInfo.width = e.width),
                e.height && (this.videoInfo.height = e.height),
                this.videoInfo.encType &&
                    this.videoInfo.height &&
                    this.videoInfo.width &&
                    !this.init &&
                    (this.player.emit(E.videoInfo, this.videoInfo),
                    (this.init = !0));
        }
    }
    class Se extends we {
        constructor(e) {
            super(), (this.player = e);
            const t = document.createElement('canvas');
            (t.style.position = 'absolute'),
                (t.style.top = 0),
                (t.style.left = 0),
                (this.$videoElement = t),
                e.$container.appendChild(this.$videoElement),
                (this.context2D = null),
                (this.contextGl = null),
                (this.contextGlRender = null),
                (this.contextGlDestroy = null),
                (this.bitmaprenderer = null),
                (this.renderType = null),
                (this.videoInfo = { width: '', height: '', encType: '' }),
                this._initCanvasRender(),
                this.player.debug.log('CanvasVideo', 'init');
        }
        destroy() {
            this.contextGl && (this.contextGl = null),
                this.context2D && (this.context2D = null),
                this.contextGlRender &&
                    (this.contextGlDestroy && this.contextGlDestroy(),
                    (this.contextGlDestroy = null),
                    (this.contextGlRender = null)),
                this.bitmaprenderer && (this.bitmaprenderer = null),
                (this.renderType = null),
                (this.videoInfo = {
                    width: '',
                    height: '',
                    encType: '',
                    encTypeCode: '',
                }),
                this.player.$container.removeChild(this.$videoElement),
                (this.init = !1),
                this.off(),
                this.player.debug.log('CanvasVideoLoader', 'destroy');
        }
        _initContextGl() {
            this.contextGl = (function (e) {
                let t = null;
                const i = [
                    'webgl',
                    'experimental-webgl',
                    'moz-webgl',
                    'webkit-3d',
                ];
                let o = 0;
                for (; !t && o < i.length; ) {
                    const r = i[o];
                    try {
                        let i = { preserveDrawingBuffer: !0 };
                        t = e.getContext(r, i);
                    } catch (e) {
                        t = null;
                    }
                    (t && 'function' == typeof t.getParameter) || (t = null),
                        ++o;
                }
                return t;
            })(this.$videoElement);
            const e = ((e) => {
                var t = [
                        'attribute vec4 vertexPos;',
                        'attribute vec4 texturePos;',
                        'varying vec2 textureCoord;',
                        'void main()',
                        '{',
                        'gl_Position = vertexPos;',
                        'textureCoord = texturePos.xy;',
                        '}',
                    ].join('\n'),
                    i = [
                        'precision highp float;',
                        'varying highp vec2 textureCoord;',
                        'uniform sampler2D ySampler;',
                        'uniform sampler2D uSampler;',
                        'uniform sampler2D vSampler;',
                        'const mat4 YUV2RGB = mat4',
                        '(',
                        '1.1643828125, 0, 1.59602734375, -.87078515625,',
                        '1.1643828125, -.39176171875, -.81296875, .52959375,',
                        '1.1643828125, 2.017234375, 0, -1.081390625,',
                        '0, 0, 0, 1',
                        ');',
                        'void main(void) {',
                        'highp float y = texture2D(ySampler,  textureCoord).r;',
                        'highp float u = texture2D(uSampler,  textureCoord).r;',
                        'highp float v = texture2D(vSampler,  textureCoord).r;',
                        'gl_FragColor = vec4(y, u, v, 1) * YUV2RGB;',
                        '}',
                    ].join('\n'),
                    o = e.createShader(e.VERTEX_SHADER);
                e.shaderSource(o, t),
                    e.compileShader(o),
                    e.getShaderParameter(o, e.COMPILE_STATUS) ||
                        console.log(
                            'Vertex shader failed to compile: ' +
                                e.getShaderInfoLog(o)
                        );
                var r = e.createShader(e.FRAGMENT_SHADER);
                e.shaderSource(r, i),
                    e.compileShader(r),
                    e.getShaderParameter(r, e.COMPILE_STATUS) ||
                        console.log(
                            'Fragment shader failed to compile: ' +
                                e.getShaderInfoLog(r)
                        );
                var A = e.createProgram();
                e.attachShader(A, o),
                    e.attachShader(A, r),
                    e.linkProgram(A),
                    e.getProgramParameter(A, e.LINK_STATUS) ||
                        console.log(
                            'Program failed to compile: ' +
                                e.getProgramInfoLog(A)
                        ),
                    e.useProgram(A);
                var s = e.createBuffer();
                e.bindBuffer(e.ARRAY_BUFFER, s),
                    e.bufferData(
                        e.ARRAY_BUFFER,
                        new Float32Array([1, 1, -1, 1, 1, -1, -1, -1]),
                        e.STATIC_DRAW
                    );
                var n = e.getAttribLocation(A, 'vertexPos');
                e.enableVertexAttribArray(n),
                    e.vertexAttribPointer(n, 2, e.FLOAT, !1, 0, 0);
                var a = e.createBuffer();
                e.bindBuffer(e.ARRAY_BUFFER, a),
                    e.bufferData(
                        e.ARRAY_BUFFER,
                        new Float32Array([1, 0, 0, 0, 1, 1, 0, 1]),
                        e.STATIC_DRAW
                    );
                var d = e.getAttribLocation(A, 'texturePos');
                function c(t, i) {
                    var o = e.createTexture();
                    return (
                        e.bindTexture(e.TEXTURE_2D, o),
                        e.texParameteri(
                            e.TEXTURE_2D,
                            e.TEXTURE_MAG_FILTER,
                            e.LINEAR
                        ),
                        e.texParameteri(
                            e.TEXTURE_2D,
                            e.TEXTURE_MIN_FILTER,
                            e.LINEAR
                        ),
                        e.texParameteri(
                            e.TEXTURE_2D,
                            e.TEXTURE_WRAP_S,
                            e.CLAMP_TO_EDGE
                        ),
                        e.texParameteri(
                            e.TEXTURE_2D,
                            e.TEXTURE_WRAP_T,
                            e.CLAMP_TO_EDGE
                        ),
                        e.bindTexture(e.TEXTURE_2D, null),
                        e.uniform1i(e.getUniformLocation(A, t), i),
                        o
                    );
                }
                e.enableVertexAttribArray(d),
                    e.vertexAttribPointer(d, 2, e.FLOAT, !1, 0, 0);
                var l = c('ySampler', 0),
                    u = c('uSampler', 1),
                    h = c('vSampler', 2);
                return {
                    render: function (t, i, o, r, A) {
                        e.viewport(0, 0, t, i),
                            e.activeTexture(e.TEXTURE0),
                            e.bindTexture(e.TEXTURE_2D, l),
                            e.texImage2D(
                                e.TEXTURE_2D,
                                0,
                                e.LUMINANCE,
                                t,
                                i,
                                0,
                                e.LUMINANCE,
                                e.UNSIGNED_BYTE,
                                o
                            ),
                            e.activeTexture(e.TEXTURE1),
                            e.bindTexture(e.TEXTURE_2D, u),
                            e.texImage2D(
                                e.TEXTURE_2D,
                                0,
                                e.LUMINANCE,
                                t / 2,
                                i / 2,
                                0,
                                e.LUMINANCE,
                                e.UNSIGNED_BYTE,
                                r
                            ),
                            e.activeTexture(e.TEXTURE2),
                            e.bindTexture(e.TEXTURE_2D, h),
                            e.texImage2D(
                                e.TEXTURE_2D,
                                0,
                                e.LUMINANCE,
                                t / 2,
                                i / 2,
                                0,
                                e.LUMINANCE,
                                e.UNSIGNED_BYTE,
                                A
                            ),
                            e.drawArrays(e.TRIANGLE_STRIP, 0, 4);
                    },
                    destroy: function () {
                        try {
                            e.deleteProgram(A),
                                e.deleteBuffer(s),
                                e.deleteBuffer(a),
                                e.deleteTexture(l),
                                e.deleteTexture(u),
                                e.deleteBuffer(h);
                        } catch (e) {}
                    },
                };
            })(this.contextGl);
            (this.contextGlRender = e.render),
                (this.contextGlDestroy = e.destroy);
        }
        _initContext2D() {
            this.context2D = this.$videoElement.getContext('2d');
        }
        _initCanvasRender() {
            this.player._opt.useWCS && !this._supportOffscreen()
                ? ((this.renderType = N), this._initContext2D())
                : this._supportOffscreen()
                ? ((this.renderType = z), this._bindOffscreen())
                : ((this.renderType = P), this._initContextGl());
        }
        _supportOffscreen() {
            return (
                'function' ==
                    typeof this.$videoElement.transferControlToOffscreen &&
                this.player._opt.useOffscreen
            );
        }
        _bindOffscreen() {
            this.bitmaprenderer =
                this.$videoElement.getContext('bitmaprenderer');
        }
        initCanvasViewSize() {
            (this.$videoElement.width = this.videoInfo.width),
                (this.$videoElement.height = this.videoInfo.height),
                this.resize();
        }
        render(e) {
            switch (((this.player.videoTimestamp = e.ts), this.renderType)) {
                case z:
                    this.bitmaprenderer.transferFromImageBitmap(e.buffer);
                    break;
                case P:
                    this.contextGlRender(
                        this.$videoElement.width,
                        this.$videoElement.height,
                        e.output[0],
                        e.output[1],
                        e.output[2]
                    );
                    break;
                case N:
                    this.context2D.drawImage(
                        e.videoFrame,
                        0,
                        0,
                        this.$videoElement.width,
                        this.$videoElement.height
                    );
            }
        }
        screenshot(e, t, i, o) {
            (e = e || ce()), (o = o || D.download);
            const r = {
                png: 'image/png',
                jpeg: 'image/jpeg',
                webp: 'image/webp',
            };
            let A = 0.92;
            !r[t] && D[t] && ((o = t), (t = 'png'), (i = void 0)),
                'string' == typeof i && ((o = i), (i = void 0)),
                void 0 !== i && (A = Number(i));
            const s = this.$videoElement.toDataURL(r[t] || r.png, A),
                n = ae(s);
            return o === D.base64
                ? s
                : o === D.blob
                ? n
                : void (o === D.download && de(n, e));
        }
        clearView() {
            switch (this.renderType) {
                case z:
                    (function (e, t) {
                        const i = document.createElement('canvas');
                        return (
                            (i.width = e),
                            (i.height = t),
                            createImageBitmap(i, 0, 0, e, t)
                        );
                    })(
                        this.$videoElement.width,
                        this.$videoElement.height
                    ).then((e) => {
                        this.bitmaprenderer.transferFromImageBitmap(e);
                    });
                    break;
                case P:
                    this.contextGl.clear(this.contextGl.COLOR_BUFFER_BIT);
                    break;
                case N:
                    this.context2D.clearRect(
                        0,
                        0,
                        this.$videoElement.width,
                        this.$videoElement.height
                    );
            }
        }
        resize() {
            this.player.debug.log('canvasVideo', 'resize');
            const e = this.player._opt,
                t = this.player.width;
            let i = this.player.height;
            e.hasControl && (i -= 38);
            let o = this.$videoElement.width,
                r = this.$videoElement.height;
            const A = e.rotate;
            let s = (t - o) / 2,
                n = (i - r) / 2;
            (270 !== A && 90 !== A) ||
                ((o = this.$videoElement.height),
                (r = this.$videoElement.width));
            const a = t / o,
                d = i / r;
            let c = a > d ? d : a;
            e.isResize || (a !== d && (c = a + ',' + d)),
                e.isFullResize && (c = a > d ? a : d);
            let l = 'scale(' + c + ')';
            A && (l += ' rotate(' + A + 'deg)'),
                (this.$videoElement.style.transform = l),
                (this.$videoElement.style.left = s + 'px'),
                (this.$videoElement.style.top = n + 'px');
        }
    }
    class Ee extends we {
        constructor(e) {
            super(), (this.player = e);
            const t = document.createElement('video');
            (t.muted = !0),
                (t.style.position = 'absolute'),
                (t.style.top = 0),
                (t.style.left = 0),
                e.$container.appendChild(t),
                (this.$videoElement = t),
                (this.videoInfo = { width: '', height: '', encType: '' }),
                this.resize();
            const { proxy: i } = this.player.events;
            i(this.$videoElement, 'canplay', () => {
                this.player.debug.log('Video', 'canplay');
            }),
                i(this.$videoElement, 'waiting', () => {
                    this.player.emit(E.videoWaiting);
                }),
                i(this.$videoElement, 'timeupdate', (e) => {}),
                this.player.debug.log('Video', 'init');
        }
        destroy() {
            this.player.$container.removeChild(this.$videoElement),
                (this.$videoElement = null),
                (this.init = !1),
                this.off(),
                this.player.debug.log('Video', 'destroy');
        }
        play() {
            this.$videoElement.play();
        }
        clearView() {}
        screenshot(e, t, i, o) {
            (e = e || ce()), (o = o || D.download);
            let r = 0.92;
            !{ png: 'image/png', jpeg: 'image/jpeg', webp: 'image/webp' }[t] &&
                D[t] &&
                ((o = t), (t = 'png'), (i = void 0)),
                'string' == typeof i && ((o = i), (i = void 0)),
                void 0 !== i && (r = Number(i));
            const A = this.$videoElement;
            let s = document.createElement('canvas');
            (s.width = A.videoWidth), (s.height = A.videoHeight);
            s.getContext('2d').drawImage(A, 0, 0, s.width, s.height);
            const n = s.toDataURL(D[t] || D.png, r),
                a = ae(n);
            return o === D.base64
                ? n
                : o === D.blob
                ? a
                : void (o === D.download && de(a, e));
        }
        initCanvasViewSize() {
            this.resize();
        }
        resize() {
            (this.$videoElement.width = this.player.width),
                (this.$videoElement.height = this.player._opt.hasControl
                    ? this.player.height - 38
                    : this.player.height);
            const e = this.player._opt;
            let t = 'contain';
            const i = e.rotate;
            e.isResize || (t = 'fill'),
                e.isFullResize && (t = 'none'),
                (this.$videoElement.style.objectFit = t),
                (this.$videoElement.style.transform = 'rotate(' + i + 'deg)');
        }
    }
    class Be {
        constructor(e) {
            return new (Be.getLoaderFactory(e._opt))(e);
        }
        static getLoaderFactory(e) {
            return e.useMSE ? Ee : Se;
        }
    }
    class Ce extends ve {
        constructor(e) {
            super(),
                (this.bufferList = []),
                (this.player = e),
                (this.scriptNode = null),
                (this.hasInitScriptNode = !1),
                (this.audioContextChannel = null),
                (this.audioContext = new (window.AudioContext ||
                    window.webkitAudioContext)()),
                (this.gainNode = this.audioContext.createGain());
            const t = this.audioContext.createBufferSource();
            (t.buffer = this.audioContext.createBuffer(1, 1, 22050)),
                t.connect(this.audioContext.destination),
                t.noteOn ? t.noteOn(0) : t.start(0),
                (this.audioBufferSourceNode = t),
                (this.mediaStreamAudioDestinationNode =
                    this.audioContext.createMediaStreamDestination()),
                this.audioEnabled(!0),
                (this.gainNode.gain.value = 0),
                (this.playing = !1),
                (this.audioSyncVideoOption = { diff: null }),
                (this.audioInfo = {
                    encType: '',
                    channels: '',
                    sampleRate: '',
                }),
                (this.init = !1),
                (this.hasAudio = !1),
                this.on(E.videoSyncAudio, (e) => {
                    this.player.debug.log(
                        'AudioContext',
                        `videoSyncAudio , audioTimestamp: ${e.audioTimestamp},videoTimestamp: ${e.videoTimestamp},diff:${e.diff}`
                    ),
                        (this.audioSyncVideoOption = e);
                }),
                this.player.debug.log('AudioContext', 'init');
        }
        destroy() {
            this.closeAudio(),
                this.audioContext.close(),
                (this.audioContext = null),
                (this.gainNode = null),
                (this.init = !1),
                (this.hasAudio = !1),
                (this.playing = !1),
                this.scriptNode &&
                    ((this.scriptNode.onaudioprocess = ne),
                    (this.scriptNode = null)),
                (this.audioBufferSourceNode = null),
                (this.mediaStreamAudioDestinationNode = null),
                (this.hasInitScriptNode = !1),
                (this.audioSyncVideoOption = { diff: null }),
                (this.audioInfo = {
                    encType: '',
                    channels: '',
                    sampleRate: '',
                }),
                this.off(),
                this.player.debug.log('AudioContext', 'destroy');
        }
        updateAudioInfo(e) {
            e.encTypeCode && (this.audioInfo.encType = U[e.encTypeCode]),
                e.channels && (this.audioInfo.channels = e.channels),
                e.sampleRate && (this.audioInfo.sampleRate = e.sampleRate),
                this.audioInfo.sampleRate &&
                    this.audioInfo.channels &&
                    this.audioInfo.encType &&
                    !this.init &&
                    (this.player.emit(E.audioInfo, this.audioInfo),
                    (this.init = !0));
        }
        get isPlaying() {
            return this.playing;
        }
        get isMute() {
            return 0 === this.gainNode.gain.value || this.isStateSuspended();
        }
        get volume() {
            return this.gainNode.gain.value;
        }
        get bufferSize() {
            return this.bufferList.length;
        }
        initScriptNode() {
            if (((this.playing = !0), this.hasInitScriptNode)) return;
            const e = this.audioInfo.channels,
                t = this.audioContext.createScriptProcessor(1024, 0, e);
            (t.onaudioprocess = (t) => {
                const i = t.outputBuffer;
                if (this.bufferList.length && this.playing) {
                    if (!this.player._opt.useWCS && !this.player._opt.useMSE) {
                        if (this.audioSyncVideoOption.diff > _)
                            return void this.player.debug.warn(
                                'AudioContext',
                                `audioSyncVideoOption more than diff :${this.audioSyncVideoOption.diff}, waiting`
                            );
                        if (this.audioSyncVideoOption.diff < -1e3) {
                            this.player.debug.warn(
                                'AudioContext',
                                `audioSyncVideoOption less than diff :${this.audioSyncVideoOption.diff}, dropping`
                            );
                            let e = this.bufferList.shift();
                            for (
                                ;
                                e.ts - this.player.videoTimestamp < -1e3 &&
                                this.bufferList.length > 0;

                            )
                                e = this.bufferList.shift();
                            if (0 === this.bufferList.length) return;
                        }
                    }
                    if (0 === this.bufferList.length) return;
                    const t = this.bufferList.shift();
                    t && t.ts && (this.player.audioTimestamp = t.ts);
                    for (let o = 0; o < e; o++) {
                        const e = t.buffer[o],
                            r = i.getChannelData(o);
                        for (let t = 0; t < 1024; t++) r[t] = e[t] || 0;
                    }
                }
            }),
                t.connect(this.gainNode),
                (this.scriptNode = t),
                this.gainNode.connect(this.audioContext.destination),
                this.gainNode.connect(this.mediaStreamAudioDestinationNode),
                (this.hasInitScriptNode = !0);
        }
        mute(e) {
            e
                ? (this.isMute || this.player.emit(E.mute, e),
                  this.setVolume(0),
                  this.audioEnabled(!1),
                  this.clear())
                : (this.isMute && this.player.emit(E.mute, e),
                  this.setVolume(0.5),
                  this.audioEnabled(!0));
        }
        setVolume(e) {
            (e = parseFloat(e).toFixed(2)),
                isNaN(e) ||
                    (this.audioEnabled(!0),
                    (e = le(e, 0, 1)),
                    (this.gainNode.gain.value = e),
                    this.gainNode.gain.setValueAtTime(
                        e,
                        this.audioContext.currentTime
                    ),
                    this.player.emit(E.volumechange, this.player.volume));
        }
        closeAudio() {
            this.hasInitScriptNode &&
                (this.scriptNode && this.scriptNode.disconnect(this.gainNode),
                this.gainNode &&
                    this.gainNode.disconnect(this.audioContext.destination),
                this.gainNode &&
                    this.gainNode.disconnect(
                        this.mediaStreamAudioDestinationNode
                    )),
                this.clear();
        }
        audioEnabled(e) {
            e
                ? 'suspended' === this.audioContext.state &&
                  this.audioContext.resume()
                : 'running' === this.audioContext.state &&
                  this.audioContext.suspend();
        }
        isStateRunning() {
            return 'running' === this.audioContext.state;
        }
        isStateSuspended() {
            return 'suspended' === this.audioContext.state;
        }
        clear() {
            this.bufferList = [];
        }
        play(e, t) {
            this.isMute ||
                ((this.hasAudio = !0),
                this.bufferList.push({ buffer: e, ts: t }),
                this.bufferList.length > 20 &&
                    (this.player.debug.warn(
                        'AudioContext',
                        `bufferList is large: ${this.bufferList.length}`
                    ),
                    this.bufferList.length > 50 && this.bufferList.shift()));
        }
        pause() {
            (this.audioSyncVideoOption = { diff: null }),
                (this.playing = !1),
                this.clear();
        }
        resume() {
            this.playing = !0;
        }
    }
    class Re {
        constructor(e) {
            return new (Re.getLoaderFactory())(e);
        }
        static getLoaderFactory() {
            return Ce;
        }
    }
    class ke extends ve {
        constructor(e) {
            super(),
                (this.player = e),
                (this.playing = !1),
                (this.abortController = new AbortController()),
                (this.streamRate = me((t) => {
                    e.emit(E.kBps, (t / 1024).toFixed(2));
                })),
                e.debug.log('FetchStream', 'init');
        }
        destroy() {
            this.abort(),
                this.off(),
                (this.streamRate = null),
                this.player.debug.log('FetchStream', 'destroy');
        }
        fetchStream(e) {
            const { demux: t } = this.player;
            (this.player._times.streamStart = ce()),
                fetch(e, { signal: this.abortController.signal })
                    .then((e) => {
                        const i = e.body.getReader();
                        this.emit(E.streamSuccess);
                        const o = () => {
                            i.read()
                                .then((e) => {
                                    let { done: i, value: r } = e;
                                    i
                                        ? t.close()
                                        : (this.streamRate &&
                                              this.streamRate(r.byteLength),
                                          t.dispatch(r),
                                          o());
                                })
                                .catch((e) => {
                                    t.close(),
                                        this.emit(C.fetchError, e),
                                        this.player.emit(E.error, C.fetchError),
                                        this.abort();
                                });
                        };
                        o();
                    })
                    .catch((e) => {
                        this.abort(),
                            this.emit(C.fetchError, e),
                            this.player.emit(E.error, C.fetchError);
                    });
        }
        abort() {
            this.abortController &&
                (this.abortController.abort(), (this.abortController = null));
        }
    }
    class Te extends ve {
        constructor(e) {
            super(),
                (this.player = e),
                (this.socket = null),
                (this.socketStatus = R),
                (this.wsUrl = null),
                (this.streamRate = me((t) => {
                    e.emit(E.kBps, (t / 1024).toFixed(2));
                }));
        }
        destroy() {
            this.socket && (this.socket.close(), (this.socket = null)),
                (this.socketStatus = R),
                (this.streamRate = null),
                (this.wsUrl = null),
                this.off(),
                this.player.debug.log('websocketLoader', 'destroy');
        }
        _createWebSocket() {
            const e = this.player,
                {
                    debug: t,
                    events: { proxy: i },
                    demux: o,
                } = e;
            (this.socket = new WebSocket(this.wsUrl)),
                (this.socket.binaryType = 'arraybuffer'),
                i(this.socket, 'open', () => {
                    this.emit(E.streamSuccess),
                        t.log('websocketLoader', 'socket open'),
                        (this.socketStatus = k);
                }),
                i(this.socket, 'message', (e) => {
                    this.streamRate && this.streamRate(e.data.byteLength),
                        this._handleMessage(e.data);
                }),
                i(this.socket, 'close', () => {
                    t.log('websocketLoader', 'socket close'),
                        this.emit(E.streamEnd),
                        (this.socketStatus = T);
                }),
                i(this.socket, 'error', (e) => {
                    t.log('websocketLoader', 'socket error'),
                        this.emit(C.websocketError, e),
                        this.player.emit(E.error, C.websocketError),
                        (this.socketStatus = I),
                        o.close(),
                        t.log('websocketLoader', 'socket error:', e);
                });
        }
        _handleMessage(e) {
            const { demux: t } = this.player;
            t
                ? t.dispatch(e)
                : this.player.debug.warn(
                      'websocketLoader',
                      'websocket handle message demux is null'
                  );
        }
        fetchStream(e) {
            (this.player._times.streamStart = ce()),
                (this.wsUrl = e),
                this._createWebSocket();
        }
    }
    class Ie {
        constructor(e) {
            return new (Ie.getLoaderFactory(e._opt.protocol))(e);
        }
        static getLoaderFactory(i) {
            return i === t ? ke : i === e ? Te : void 0;
        }
    }
    var De = Ae(function (e) {
        function t(e, r) {
            if (!e) throw 'First parameter is required.';
            r = new i(e, (r = r || { type: 'video' }));
            var A = this;
            function s(t) {
                t &&
                    (r.initCallback = function () {
                        t(), (t = r.initCallback = null);
                    });
                var i = new o(e, r);
                (h = new i(e, r)).record(),
                    u('recording'),
                    r.disableLogs ||
                        console.log(
                            'Initialized recorderType:',
                            h.constructor.name,
                            'for output-type:',
                            r.type
                        );
            }
            function n(e) {
                if (((e = e || function () {}), h)) {
                    if ('paused' === A.state)
                        return (
                            A.resumeRecording(),
                            void setTimeout(function () {
                                n(e);
                            }, 1)
                        );
                    'recording' === A.state ||
                        r.disableLogs ||
                        console.warn(
                            'Recording state should be: "recording", however current state is: ',
                            A.state
                        ),
                        r.disableLogs ||
                            console.log(
                                'Stopped recording ' + r.type + ' stream.'
                            ),
                        'gif' !== r.type ? h.stop(t) : (h.stop(), t()),
                        u('stopped');
                } else m();
                function t(t) {
                    if (h) {
                        Object.keys(h).forEach(function (e) {
                            'function' != typeof h[e] && (A[e] = h[e]);
                        });
                        var i = h.blob;
                        if (!i) {
                            if (!t) throw 'Recording failed.';
                            h.blob = i = t;
                        }
                        if (
                            (i &&
                                !r.disableLogs &&
                                console.log(i.type, '->', f(i.size)),
                            e)
                        ) {
                            var o;
                            try {
                                o = c.createObjectURL(i);
                            } catch (e) {}
                            'function' == typeof e.call ? e.call(A, o) : e(o);
                        }
                        r.autoWriteToDisk &&
                            d(function (e) {
                                var t = {};
                                (t[r.type + 'Blob'] = e), I.Store(t);
                            });
                    } else 'function' == typeof e.call ? e.call(A, '') : e('');
                }
            }
            function a(e) {
                postMessage(new FileReaderSync().readAsDataURL(e));
            }
            function d(e, t) {
                if (!e) throw 'Pass a callback function over getDataURL.';
                var i = t ? t.blob : (h || {}).blob;
                if (!i)
                    return (
                        r.disableLogs ||
                            console.warn(
                                'Blob encoder did not finish its job yet.'
                            ),
                        void setTimeout(function () {
                            d(e, t);
                        }, 1e3)
                    );
                if ('undefined' == typeof Worker || navigator.mozGetUserMedia) {
                    var o = new FileReader();
                    o.readAsDataURL(i),
                        (o.onload = function (t) {
                            e(t.target.result);
                        });
                } else {
                    var A = (function (e) {
                        try {
                            var t = c.createObjectURL(
                                    new Blob(
                                        [
                                            e.toString(),
                                            'this.onmessage =  function (eee) {' +
                                                e.name +
                                                '(eee.data);}',
                                        ],
                                        { type: 'application/javascript' }
                                    )
                                ),
                                i = new Worker(t);
                            return c.revokeObjectURL(t), i;
                        } catch (e) {}
                    })(a);
                    (A.onmessage = function (t) {
                        e(t.data);
                    }),
                        A.postMessage(i);
                }
            }
            function l(e) {
                (e = e || 0),
                    'paused' !== A.state
                        ? 'stopped' !== A.state &&
                          (e >= A.recordingDuration
                              ? n(A.onRecordingStopped)
                              : ((e += 1e3),
                                setTimeout(function () {
                                    l(e);
                                }, 1e3)))
                        : setTimeout(function () {
                              l(e);
                          }, 1e3);
            }
            function u(e) {
                A &&
                    ((A.state = e),
                    'function' == typeof A.onStateChanged.call
                        ? A.onStateChanged.call(A, e)
                        : A.onStateChanged(e));
            }
            var h,
                p =
                    'It seems that recorder is destroyed or "startRecording" is not invoked for ' +
                    r.type +
                    ' recorder.';
            function m() {
                !0 !== r.disableLogs && console.warn(p);
            }
            var g = {
                startRecording: function (t) {
                    return (
                        r.disableLogs ||
                            console.log('RecordRTC version: ', A.version),
                        t && (r = new i(e, t)),
                        r.disableLogs ||
                            console.log(
                                'started recording ' + r.type + ' stream.'
                            ),
                        h
                            ? (h.clearRecordedData(),
                              h.record(),
                              u('recording'),
                              A.recordingDuration && l(),
                              A)
                            : (s(function () {
                                  A.recordingDuration && l();
                              }),
                              A)
                    );
                },
                stopRecording: n,
                pauseRecording: function () {
                    h
                        ? 'recording' === A.state
                            ? (u('paused'),
                              h.pause(),
                              r.disableLogs || console.log('Paused recording.'))
                            : r.disableLogs ||
                              console.warn(
                                  'Unable to pause the recording. Recording state: ',
                                  A.state
                              )
                        : m();
                },
                resumeRecording: function () {
                    h
                        ? 'paused' === A.state
                            ? (u('recording'),
                              h.resume(),
                              r.disableLogs ||
                                  console.log('Resumed recording.'))
                            : r.disableLogs ||
                              console.warn(
                                  'Unable to resume the recording. Recording state: ',
                                  A.state
                              )
                        : m();
                },
                initRecorder: s,
                setRecordingDuration: function (e, t) {
                    if (void 0 === e) throw 'recordingDuration is required.';
                    if ('number' != typeof e)
                        throw 'recordingDuration must be a number.';
                    return (
                        (A.recordingDuration = e),
                        (A.onRecordingStopped = t || function () {}),
                        {
                            onRecordingStopped: function (e) {
                                A.onRecordingStopped = e;
                            },
                        }
                    );
                },
                clearRecordedData: function () {
                    h
                        ? (h.clearRecordedData(),
                          r.disableLogs ||
                              console.log('Cleared old recorded data.'))
                        : m();
                },
                getBlob: function () {
                    if (h) return h.blob;
                    m();
                },
                getDataURL: d,
                toURL: function () {
                    if (h) return c.createObjectURL(h.blob);
                    m();
                },
                getInternalRecorder: function () {
                    return h;
                },
                save: function (e) {
                    h ? b(h.blob, e) : m();
                },
                getFromDisk: function (e) {
                    h ? t.getFromDisk(r.type, e) : m();
                },
                setAdvertisementArray: function (e) {
                    r.advertisement = [];
                    for (var t = e.length, i = 0; i < t; i++)
                        r.advertisement.push({ duration: i, image: e[i] });
                },
                blob: null,
                bufferSize: 0,
                sampleRate: 0,
                buffer: null,
                reset: function () {
                    'recording' !== A.state ||
                        r.disableLogs ||
                        console.warn('Stop an active recorder.'),
                        h &&
                            'function' == typeof h.clearRecordedData &&
                            h.clearRecordedData(),
                        (h = null),
                        u('inactive'),
                        (A.blob = null);
                },
                onStateChanged: function (e) {
                    r.disableLogs || console.log('Recorder state changed:', e);
                },
                state: 'inactive',
                getState: function () {
                    return A.state;
                },
                destroy: function () {
                    var e = r.disableLogs;
                    (r = { disableLogs: !0 }),
                        A.reset(),
                        u('destroyed'),
                        (g = A = null),
                        S.AudioContextConstructor &&
                            (S.AudioContextConstructor.close(),
                            (S.AudioContextConstructor = null)),
                        (r.disableLogs = e),
                        r.disableLogs || console.log('RecordRTC is destroyed.');
                },
                version: '5.6.2',
            };
            if (!this) return (A = g), g;
            for (var y in g) this[y] = g[y];
            return (A = this), g;
        }
        function i(e, t) {
            return (
                t.recorderType ||
                    t.type ||
                    (t.audio && t.video
                        ? (t.type = 'video')
                        : t.audio && !t.video && (t.type = 'audio')),
                t.recorderType &&
                    !t.type &&
                    (t.recorderType === k ||
                    t.recorderType === R ||
                    t.recorderType === j
                        ? (t.type = 'video')
                        : t.recorderType === D
                        ? (t.type = 'gif')
                        : t.recorderType === C
                        ? (t.type = 'audio')
                        : t.recorderType === B &&
                          ((v(e, 'audio').length && v(e, 'video').length) ||
                          (!v(e, 'audio').length && v(e, 'video').length)
                              ? (t.type = 'video')
                              : v(e, 'audio').length &&
                                !v(e, 'video').length &&
                                (t.type = 'audio'))),
                'undefined' != typeof MediaRecorder &&
                    'requestData' in MediaRecorder.prototype &&
                    (t.mimeType || (t.mimeType = 'video/webm'),
                    t.type || (t.type = t.mimeType.split('/')[0]),
                    t.bitsPerSecond),
                t.type ||
                    (t.mimeType && (t.type = t.mimeType.split('/')[0]),
                    t.type || (t.type = 'audio')),
                t
            );
        }
        function o(e, t) {
            var i;
            return (
                (p || l || u) && (i = C),
                'undefined' != typeof MediaRecorder &&
                    'requestData' in MediaRecorder.prototype &&
                    !p &&
                    (i = B),
                'video' === t.type &&
                    (p || u) &&
                    ((i = k), 'undefined' != typeof ReadableStream && (i = j)),
                'gif' === t.type && (i = D),
                'canvas' === t.type && (i = R),
                E() &&
                    i !== R &&
                    i !== D &&
                    'undefined' != typeof MediaRecorder &&
                    'requestData' in MediaRecorder.prototype &&
                    (v(e, 'video').length || v(e, 'audio').length) &&
                    ('audio' === t.type
                        ? 'function' == typeof MediaRecorder.isTypeSupported &&
                          MediaRecorder.isTypeSupported('audio/webm') &&
                          (i = B)
                        : 'function' == typeof MediaRecorder.isTypeSupported &&
                          MediaRecorder.isTypeSupported('video/webm') &&
                          (i = B)),
                e instanceof Array && e.length && (i = L),
                t.recorderType && (i = t.recorderType),
                !t.disableLogs &&
                    i &&
                    i.name &&
                    console.log(
                        'Using recorderType:',
                        i.name || i.constructor.name
                    ),
                !i && m && (i = B),
                i
            );
        }
        function r(e) {
            (this.addStream = function (t) {
                t && (e = t);
            }),
                (this.mediaType = { audio: !0, video: !0 }),
                (this.startRecording = function () {
                    var i,
                        o = this.mediaType,
                        r = this.mimeType || {
                            audio: null,
                            video: null,
                            gif: null,
                        };
                    if (
                        ('function' != typeof o.audio &&
                            E() &&
                            !v(e, 'audio').length &&
                            (o.audio = !1),
                        'function' != typeof o.video &&
                            E() &&
                            !v(e, 'video').length &&
                            (o.video = !1),
                        'function' != typeof o.gif &&
                            E() &&
                            !v(e, 'video').length &&
                            (o.gif = !1),
                        !o.audio && !o.video && !o.gif)
                    )
                        throw 'MediaStream must have either audio or video tracks.';
                    if (
                        (o.audio &&
                            ((i = null),
                            'function' == typeof o.audio && (i = o.audio),
                            (this.audioRecorder = new t(e, {
                                type: 'audio',
                                bufferSize: this.bufferSize,
                                sampleRate: this.sampleRate,
                                numberOfAudioChannels:
                                    this.numberOfAudioChannels || 2,
                                disableLogs: this.disableLogs,
                                recorderType: i,
                                mimeType: r.audio,
                                timeSlice: this.timeSlice,
                                onTimeStamp: this.onTimeStamp,
                            })),
                            o.video || this.audioRecorder.startRecording()),
                        o.video)
                    ) {
                        (i = null),
                            'function' == typeof o.video && (i = o.video);
                        var A = e;
                        if (E() && o.audio && 'function' == typeof o.audio) {
                            var s = v(e, 'video')[0];
                            h
                                ? ((A = new g()).addTrack(s),
                                  i && i === k && (i = B))
                                : (A = new g()).addTrack(s);
                        }
                        (this.videoRecorder = new t(A, {
                            type: 'video',
                            video: this.video,
                            canvas: this.canvas,
                            frameInterval: this.frameInterval || 10,
                            disableLogs: this.disableLogs,
                            recorderType: i,
                            mimeType: r.video,
                            timeSlice: this.timeSlice,
                            onTimeStamp: this.onTimeStamp,
                            workerPath: this.workerPath,
                            webAssemblyPath: this.webAssemblyPath,
                            frameRate: this.frameRate,
                            bitrate: this.bitrate,
                        })),
                            o.audio || this.videoRecorder.startRecording();
                    }
                    if (o.audio && o.video) {
                        var n = this,
                            a = !0 === E();
                        ((o.audio instanceof C && o.video) ||
                            (!0 !== o.audio &&
                                !0 !== o.video &&
                                o.audio !== o.video)) &&
                            (a = !1),
                            !0 === a
                                ? ((n.audioRecorder = null),
                                  n.videoRecorder.startRecording())
                                : n.videoRecorder.initRecorder(function () {
                                      n.audioRecorder.initRecorder(function () {
                                          n.videoRecorder.startRecording(),
                                              n.audioRecorder.startRecording();
                                      });
                                  });
                    }
                    o.gif &&
                        ((i = null),
                        'function' == typeof o.gif && (i = o.gif),
                        (this.gifRecorder = new t(e, {
                            type: 'gif',
                            frameRate: this.frameRate || 200,
                            quality: this.quality || 10,
                            disableLogs: this.disableLogs,
                            recorderType: i,
                            mimeType: r.gif,
                        })),
                        this.gifRecorder.startRecording());
                }),
                (this.stopRecording = function (e) {
                    (e = e || function () {}),
                        this.audioRecorder &&
                            this.audioRecorder.stopRecording(function (t) {
                                e(t, 'audio');
                            }),
                        this.videoRecorder &&
                            this.videoRecorder.stopRecording(function (t) {
                                e(t, 'video');
                            }),
                        this.gifRecorder &&
                            this.gifRecorder.stopRecording(function (t) {
                                e(t, 'gif');
                            });
                }),
                (this.pauseRecording = function () {
                    this.audioRecorder && this.audioRecorder.pauseRecording(),
                        this.videoRecorder &&
                            this.videoRecorder.pauseRecording(),
                        this.gifRecorder && this.gifRecorder.pauseRecording();
                }),
                (this.resumeRecording = function () {
                    this.audioRecorder && this.audioRecorder.resumeRecording(),
                        this.videoRecorder &&
                            this.videoRecorder.resumeRecording(),
                        this.gifRecorder && this.gifRecorder.resumeRecording();
                }),
                (this.getBlob = function (e) {
                    var t = {};
                    return (
                        this.audioRecorder &&
                            (t.audio = this.audioRecorder.getBlob()),
                        this.videoRecorder &&
                            (t.video = this.videoRecorder.getBlob()),
                        this.gifRecorder &&
                            (t.gif = this.gifRecorder.getBlob()),
                        e && e(t),
                        t
                    );
                }),
                (this.destroy = function () {
                    this.audioRecorder &&
                        (this.audioRecorder.destroy(),
                        (this.audioRecorder = null)),
                        this.videoRecorder &&
                            (this.videoRecorder.destroy(),
                            (this.videoRecorder = null)),
                        this.gifRecorder &&
                            (this.gifRecorder.destroy(),
                            (this.gifRecorder = null));
                }),
                (this.getDataURL = function (e) {
                    function t(e, t) {
                        if ('undefined' != typeof Worker) {
                            var i = (function (e) {
                                var t,
                                    i = c.createObjectURL(
                                        new Blob(
                                            [
                                                e.toString(),
                                                'this.onmessage =  function (eee) {' +
                                                    e.name +
                                                    '(eee.data);}',
                                            ],
                                            { type: 'application/javascript' }
                                        )
                                    ),
                                    o = new Worker(i);
                                if (void 0 !== c) t = c;
                                else {
                                    if ('undefined' == typeof webkitURL)
                                        throw 'Neither URL nor webkitURL detected.';
                                    t = webkitURL;
                                }
                                return t.revokeObjectURL(i), o;
                            })(function (e) {
                                postMessage(
                                    new FileReaderSync().readAsDataURL(e)
                                );
                            });
                            (i.onmessage = function (e) {
                                t(e.data);
                            }),
                                i.postMessage(e);
                        } else {
                            var o = new FileReader();
                            o.readAsDataURL(e),
                                (o.onload = function (e) {
                                    t(e.target.result);
                                });
                        }
                    }
                    this.getBlob(function (i) {
                        i.audio && i.video
                            ? t(i.audio, function (o) {
                                  t(i.video, function (t) {
                                      e({ audio: o, video: t });
                                  });
                              })
                            : i.audio
                            ? t(i.audio, function (t) {
                                  e({ audio: t });
                              })
                            : i.video &&
                              t(i.video, function (t) {
                                  e({ video: t });
                              });
                    });
                }),
                (this.writeToDisk = function () {
                    t.writeToDisk({
                        audio: this.audioRecorder,
                        video: this.videoRecorder,
                        gif: this.gifRecorder,
                    });
                }),
                (this.save = function (e) {
                    (e = e || { audio: !0, video: !0, gif: !0 }).audio &&
                        this.audioRecorder &&
                        this.audioRecorder.save(
                            'string' == typeof e.audio ? e.audio : ''
                        ),
                        e.video &&
                            this.videoRecorder &&
                            this.videoRecorder.save(
                                'string' == typeof e.video ? e.video : ''
                            ),
                        e.gif &&
                            this.gifRecorder &&
                            this.gifRecorder.save(
                                'string' == typeof e.gif ? e.gif : ''
                            );
                });
        }
        (t.version = '5.6.2'),
            (e.exports = t),
            (t.getFromDisk = function (e, t) {
                if (!t) throw 'callback is mandatory.';
                console.log(
                    'Getting recorded ' +
                        ('all' === e ? 'blobs' : e + ' blob ') +
                        ' from disk!'
                ),
                    I.Fetch(function (i, o) {
                        'all' !== e && o === e + 'Blob' && t && t(i),
                            'all' === e && t && t(i, o.replace('Blob', ''));
                    });
            }),
            (t.writeToDisk = function (e) {
                console.log('Writing recorded blob(s) to disk!'),
                    (e = e || {}).audio && e.video && e.gif
                        ? e.audio.getDataURL(function (t) {
                              e.video.getDataURL(function (i) {
                                  e.gif.getDataURL(function (e) {
                                      I.Store({
                                          audioBlob: t,
                                          videoBlob: i,
                                          gifBlob: e,
                                      });
                                  });
                              });
                          })
                        : e.audio && e.video
                        ? e.audio.getDataURL(function (t) {
                              e.video.getDataURL(function (e) {
                                  I.Store({ audioBlob: t, videoBlob: e });
                              });
                          })
                        : e.audio && e.gif
                        ? e.audio.getDataURL(function (t) {
                              e.gif.getDataURL(function (e) {
                                  I.Store({ audioBlob: t, gifBlob: e });
                              });
                          })
                        : e.video && e.gif
                        ? e.video.getDataURL(function (t) {
                              e.gif.getDataURL(function (e) {
                                  I.Store({ videoBlob: t, gifBlob: e });
                              });
                          })
                        : e.audio
                        ? e.audio.getDataURL(function (e) {
                              I.Store({ audioBlob: e });
                          })
                        : e.video
                        ? e.video.getDataURL(function (e) {
                              I.Store({ videoBlob: e });
                          })
                        : e.gif &&
                          e.gif.getDataURL(function (e) {
                              I.Store({ gifBlob: e });
                          });
            }),
            (r.getFromDisk = t.getFromDisk),
            (r.writeToDisk = t.writeToDisk),
            (t.MRecordRTC = r);
        var A;
        (A = void 0 !== re ? re : null) &&
            'undefined' == typeof window &&
            void 0 !== re &&
            ((re.navigator = {
                userAgent:
                    'Fake/5.0 (FakeOS) AppleWebKit/123 (KHTML, like Gecko) Fake/12.3.4567.89 Fake/123.45',
                getUserMedia: function () {},
            }),
            re.console || (re.console = {}),
            (void 0 !== re.console.log && void 0 !== re.console.error) ||
                (re.console.error = re.console.log =
                    re.console.log ||
                    function () {
                        console.log(arguments);
                    }),
            'undefined' == typeof document &&
                ((A.document = {
                    documentElement: {
                        appendChild: function () {
                            return '';
                        },
                    },
                }),
                (document.createElement =
                    document.captureStream =
                    document.mozCaptureStream =
                        function () {
                            var e = {
                                getContext: function () {
                                    return e;
                                },
                                play: function () {},
                                pause: function () {},
                                drawImage: function () {},
                                toDataURL: function () {
                                    return '';
                                },
                                style: {},
                            };
                            return e;
                        }),
                (A.HTMLVideoElement = function () {})),
            'undefined' == typeof location &&
                (A.location = { protocol: 'file:', href: '', hash: '' }),
            'undefined' == typeof screen &&
                (A.screen = { width: 0, height: 0 }),
            void 0 === c &&
                (A.URL = {
                    createObjectURL: function () {
                        return '';
                    },
                    revokeObjectURL: function () {
                        return '';
                    },
                }),
            (A.window = re));
        var s = window.requestAnimationFrame;
        if (void 0 === s)
            if ('undefined' != typeof webkitRequestAnimationFrame)
                s = webkitRequestAnimationFrame;
            else if ('undefined' != typeof mozRequestAnimationFrame)
                s = mozRequestAnimationFrame;
            else if ('undefined' != typeof msRequestAnimationFrame)
                s = msRequestAnimationFrame;
            else if (void 0 === s) {
                var n = 0;
                s = function (e, t) {
                    var i = new Date().getTime(),
                        o = Math.max(0, 16 - (i - n)),
                        r = setTimeout(function () {
                            e(i + o);
                        }, o);
                    return (n = i + o), r;
                };
            }
        var a = window.cancelAnimationFrame;
        void 0 === a &&
            ('undefined' != typeof webkitCancelAnimationFrame
                ? (a = webkitCancelAnimationFrame)
                : 'undefined' != typeof mozCancelAnimationFrame
                ? (a = mozCancelAnimationFrame)
                : 'undefined' != typeof msCancelAnimationFrame
                ? (a = msCancelAnimationFrame)
                : void 0 === a &&
                  (a = function (e) {
                      clearTimeout(e);
                  }));
        var d = window.AudioContext;
        void 0 === d &&
            ('undefined' != typeof webkitAudioContext &&
                (d = webkitAudioContext),
            'undefined' != typeof mozAudioContext && (d = mozAudioContext));
        var c = window.URL;
        void 0 === c && 'undefined' != typeof webkitURL && (c = webkitURL),
            'undefined' != typeof navigator &&
                void 0 === navigator.getUserMedia &&
                (void 0 !== navigator.webkitGetUserMedia &&
                    (navigator.getUserMedia = navigator.webkitGetUserMedia),
                void 0 !== navigator.mozGetUserMedia &&
                    (navigator.getUserMedia = navigator.mozGetUserMedia));
        var l = !(
                -1 === navigator.userAgent.indexOf('Edge') ||
                (!navigator.msSaveBlob && !navigator.msSaveOrOpenBlob)
            ),
            u = !!window.opera || -1 !== navigator.userAgent.indexOf('OPR/'),
            h =
                navigator.userAgent.toLowerCase().indexOf('firefox') > -1 &&
                'netscape' in window &&
                / rv:/.test(navigator.userAgent),
            p =
                (!u && !l && !!navigator.webkitGetUserMedia) ||
                y() ||
                -1 !== navigator.userAgent.toLowerCase().indexOf('chrome/'),
            m = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
        m &&
            !p &&
            -1 !== navigator.userAgent.indexOf('CriOS') &&
            ((m = !1), (p = !0));
        var g = window.MediaStream;
        function f(e) {
            if (0 === e) return '0 Bytes';
            var t = parseInt(Math.floor(Math.log(e) / Math.log(1e3)), 10);
            return (
                (e / Math.pow(1e3, t)).toPrecision(3) +
                ' ' +
                ['Bytes', 'KB', 'MB', 'GB', 'TB'][t]
            );
        }
        function b(e, t) {
            if (!e) throw 'Blob object is required.';
            if (!e.type)
                try {
                    e.type = 'video/webm';
                } catch (e) {}
            var i = (e.type || 'video/webm').split('/')[1];
            if (
                (-1 !== i.indexOf(';') && (i = i.split(';')[0]),
                t && -1 !== t.indexOf('.'))
            ) {
                var o = t.split('.');
                (t = o[0]), (i = o[1]);
            }
            var r =
                (t || Math.round(9999999999 * Math.random()) + 888888888) +
                '.' +
                i;
            if (void 0 !== navigator.msSaveOrOpenBlob)
                return navigator.msSaveOrOpenBlob(e, r);
            if (void 0 !== navigator.msSaveBlob)
                return navigator.msSaveBlob(e, r);
            var A = document.createElement('a');
            (A.href = c.createObjectURL(e)),
                (A.download = r),
                (A.style = 'display:none;opacity:0;color:transparent;'),
                (document.body || document.documentElement).appendChild(A),
                'function' == typeof A.click
                    ? A.click()
                    : ((A.target = '_blank'),
                      A.dispatchEvent(
                          new MouseEvent('click', {
                              view: window,
                              bubbles: !0,
                              cancelable: !0,
                          })
                      )),
                c.revokeObjectURL(A.href);
        }
        function y() {
            return (
                ('undefined' != typeof window &&
                    'object' == typeof window.process &&
                    'renderer' === window.process.type) ||
                !(
                    'undefined' == typeof process ||
                    'object' != typeof process.versions ||
                    !process.versions.electron
                ) ||
                ('object' == typeof navigator &&
                    'string' == typeof navigator.userAgent &&
                    navigator.userAgent.indexOf('Electron') >= 0)
            );
        }
        function v(e, t) {
            return e && e.getTracks
                ? e.getTracks().filter(function (e) {
                      return e.kind === (t || 'audio');
                  })
                : [];
        }
        function w(e, t) {
            'srcObject' in t
                ? (t.srcObject = e)
                : 'mozSrcObject' in t
                ? (t.mozSrcObject = e)
                : (t.srcObject = e);
        }
        void 0 === g &&
            'undefined' != typeof webkitMediaStream &&
            (g = webkitMediaStream),
            void 0 !== g &&
                void 0 === g.prototype.stop &&
                (g.prototype.stop = function () {
                    this.getTracks().forEach(function (e) {
                        e.stop();
                    });
                }),
            (t.invokeSaveAsDialog = b),
            (t.getTracks = v),
            (t.getSeekableBlob = function (e, t) {
                if ('undefined' == typeof EBML)
                    throw new Error(
                        'Please link: https://www.webrtc-experiment.com/EBML.js'
                    );
                var i = new EBML.Reader(),
                    o = new EBML.Decoder(),
                    r = EBML.tools,
                    A = new FileReader();
                (A.onload = function (e) {
                    o.decode(this.result).forEach(function (e) {
                        i.read(e);
                    }),
                        i.stop();
                    var A = r.makeMetadataSeekable(
                            i.metadatas,
                            i.duration,
                            i.cues
                        ),
                        s = this.result.slice(i.metadataSize),
                        n = new Blob([A, s], { type: 'video/webm' });
                    t(n);
                }),
                    A.readAsArrayBuffer(e);
            }),
            (t.bytesToSize = f),
            (t.isElectron = y);
        var S = {};
        function E() {
            if (h || m || l) return !0;
            var e,
                t,
                i = navigator.userAgent,
                o = '' + parseFloat(navigator.appVersion),
                r = parseInt(navigator.appVersion, 10);
            return (
                (p || u) &&
                    ((e = i.indexOf('Chrome')), (o = i.substring(e + 7))),
                -1 !== (t = o.indexOf(';')) && (o = o.substring(0, t)),
                -1 !== (t = o.indexOf(' ')) && (o = o.substring(0, t)),
                (r = parseInt('' + o, 10)),
                isNaN(r) &&
                    ((o = '' + parseFloat(navigator.appVersion)),
                    (r = parseInt(navigator.appVersion, 10))),
                r >= 49
            );
        }
        function B(e, t) {
            var i = this;
            if (void 0 === e) throw 'First argument "MediaStream" is required.';
            if ('undefined' == typeof MediaRecorder)
                throw 'Your browser does not support the Media Recorder API. Please try other modules e.g. WhammyRecorder or StereoAudioRecorder.';
            if ('audio' === (t = t || { mimeType: 'video/webm' }).type) {
                var o;
                if (v(e, 'video').length && v(e, 'audio').length)
                    navigator.mozGetUserMedia
                        ? (o = new g()).addTrack(v(e, 'audio')[0])
                        : (o = new g(v(e, 'audio'))),
                        (e = o);
                (t.mimeType &&
                    -1 !==
                        t.mimeType.toString().toLowerCase().indexOf('audio')) ||
                    (t.mimeType = p ? 'audio/webm' : 'audio/ogg'),
                    t.mimeType &&
                        'audio/ogg' !== t.mimeType.toString().toLowerCase() &&
                        navigator.mozGetUserMedia &&
                        (t.mimeType = 'audio/ogg');
            }
            var r,
                A = [];
            function s() {
                i.timestamps.push(new Date().getTime()),
                    'function' == typeof t.onTimeStamp &&
                        t.onTimeStamp(
                            i.timestamps[i.timestamps.length - 1],
                            i.timestamps
                        );
            }
            function n(e) {
                return r && r.mimeType
                    ? r.mimeType
                    : e.mimeType || 'video/webm';
            }
            function a() {
                (A = []), (r = null), (i.timestamps = []);
            }
            (this.getArrayOfBlobs = function () {
                return A;
            }),
                (this.record = function () {
                    (i.blob = null),
                        i.clearRecordedData(),
                        (i.timestamps = []),
                        (d = []),
                        (A = []);
                    var o = t;
                    t.disableLogs ||
                        console.log(
                            'Passing following config over MediaRecorder API.',
                            o
                        ),
                        r && (r = null),
                        p && !E() && (o = 'video/vp8'),
                        'function' == typeof MediaRecorder.isTypeSupported &&
                            o.mimeType &&
                            (MediaRecorder.isTypeSupported(o.mimeType) ||
                                (t.disableLogs ||
                                    console.warn(
                                        'MediaRecorder API seems unable to record mimeType:',
                                        o.mimeType
                                    ),
                                (o.mimeType =
                                    'audio' === t.type
                                        ? 'audio/webm'
                                        : 'video/webm')));
                    try {
                        (r = new MediaRecorder(e, o)),
                            (t.mimeType = o.mimeType);
                    } catch (t) {
                        r = new MediaRecorder(e);
                    }
                    o.mimeType &&
                        !MediaRecorder.isTypeSupported &&
                        'canRecordMimeType' in r &&
                        !1 === r.canRecordMimeType(o.mimeType) &&
                        (t.disableLogs ||
                            console.warn(
                                'MediaRecorder API seems unable to record mimeType:',
                                o.mimeType
                            )),
                        (r.ondataavailable = function (e) {
                            if (
                                (e.data &&
                                    d.push(
                                        'ondataavailable: ' + f(e.data.size)
                                    ),
                                'number' != typeof t.timeSlice)
                            )
                                !e.data ||
                                !e.data.size ||
                                e.data.size < 100 ||
                                i.blob
                                    ? i.recordingCallback &&
                                      (i.recordingCallback(
                                          new Blob([], { type: n(o) })
                                      ),
                                      (i.recordingCallback = null))
                                    : ((i.blob = t.getNativeBlob
                                          ? e.data
                                          : new Blob([e.data], { type: n(o) })),
                                      i.recordingCallback &&
                                          (i.recordingCallback(i.blob),
                                          (i.recordingCallback = null)));
                            else if (
                                e.data &&
                                e.data.size &&
                                (A.push(e.data),
                                s(),
                                'function' == typeof t.ondataavailable)
                            ) {
                                var r = t.getNativeBlob
                                    ? e.data
                                    : new Blob([e.data], { type: n(o) });
                                t.ondataavailable(r);
                            }
                        }),
                        (r.onstart = function () {
                            d.push('started');
                        }),
                        (r.onpause = function () {
                            d.push('paused');
                        }),
                        (r.onresume = function () {
                            d.push('resumed');
                        }),
                        (r.onstop = function () {
                            d.push('stopped');
                        }),
                        (r.onerror = function (e) {
                            e &&
                                (e.name || (e.name = 'UnknownError'),
                                d.push('error: ' + e),
                                t.disableLogs ||
                                    (-1 !==
                                    e.name
                                        .toString()
                                        .toLowerCase()
                                        .indexOf('invalidstate')
                                        ? console.error(
                                              'The MediaRecorder is not in a state in which the proposed operation is allowed to be executed.',
                                              e
                                          )
                                        : -1 !==
                                          e.name
                                              .toString()
                                              .toLowerCase()
                                              .indexOf('notsupported')
                                        ? console.error(
                                              'MIME type (',
                                              o.mimeType,
                                              ') is not supported.',
                                              e
                                          )
                                        : -1 !==
                                          e.name
                                              .toString()
                                              .toLowerCase()
                                              .indexOf('security')
                                        ? console.error(
                                              'MediaRecorder security error',
                                              e
                                          )
                                        : 'OutOfMemory' === e.name
                                        ? console.error(
                                              'The UA has exhaused the available memory. User agents SHOULD provide as much additional information as possible in the message attribute.',
                                              e
                                          )
                                        : 'IllegalStreamModification' === e.name
                                        ? console.error(
                                              'A modification to the stream has occurred that makes it impossible to continue recording. An example would be the addition of a Track while recording is occurring. User agents SHOULD provide as much additional information as possible in the message attribute.',
                                              e
                                          )
                                        : 'OtherRecordingError' === e.name
                                        ? console.error(
                                              'Used for an fatal error other than those listed above. User agents SHOULD provide as much additional information as possible in the message attribute.',
                                              e
                                          )
                                        : 'GenericError' === e.name
                                        ? console.error(
                                              'The UA cannot provide the codec or recording option that has been requested.',
                                              e
                                          )
                                        : console.error(
                                              'MediaRecorder Error',
                                              e
                                          )),
                                (function (e) {
                                    if (
                                        !i.manuallyStopped &&
                                        r &&
                                        'inactive' === r.state
                                    )
                                        return (
                                            delete t.timeslice,
                                            void r.start(6e5)
                                        );
                                    setTimeout(void 0, 1e3);
                                })(),
                                'inactive' !== r.state &&
                                    'stopped' !== r.state &&
                                    r.stop());
                        }),
                        'number' == typeof t.timeSlice
                            ? (s(), r.start(t.timeSlice))
                            : r.start(36e5),
                        t.initCallback && t.initCallback();
                }),
                (this.timestamps = []),
                (this.stop = function (e) {
                    (e = e || function () {}),
                        (i.manuallyStopped = !0),
                        r &&
                            ((this.recordingCallback = e),
                            'recording' === r.state && r.stop(),
                            'number' == typeof t.timeSlice &&
                                setTimeout(function () {
                                    (i.blob = new Blob(A, { type: n(t) })),
                                        i.recordingCallback(i.blob);
                                }, 100));
                }),
                (this.pause = function () {
                    r && 'recording' === r.state && r.pause();
                }),
                (this.resume = function () {
                    r && 'paused' === r.state && r.resume();
                }),
                (this.clearRecordedData = function () {
                    r && 'recording' === r.state && i.stop(a), a();
                }),
                (this.getInternalRecorder = function () {
                    return r;
                }),
                (this.blob = null),
                (this.getState = function () {
                    return (r && r.state) || 'inactive';
                });
            var d = [];
            (this.getAllStates = function () {
                return d;
            }),
                void 0 === t.checkForInactiveTracks &&
                    (t.checkForInactiveTracks = !1);
            i = this;
            !(function o() {
                if (r && !1 !== t.checkForInactiveTracks)
                    return !1 ===
                        (function () {
                            if ('active' in e) {
                                if (!e.active) return !1;
                            } else if ('ended' in e && e.ended) return !1;
                            return !0;
                        })()
                        ? (t.disableLogs ||
                              console.log('MediaStream seems stopped.'),
                          void i.stop())
                        : void setTimeout(o, 1e3);
            })(),
                (this.name = 'MediaStreamRecorder'),
                (this.toString = function () {
                    return this.name;
                });
        }
        function C(e, i) {
            if (!v(e, 'audio').length) throw 'Your stream has no audio tracks.';
            var o,
                r = this,
                A = [],
                s = [],
                n = !1,
                a = 0,
                d = 2,
                l = (i = i || {}).desiredSampRate;
            function u() {
                if (!1 === i.checkForInactiveTracks) return !0;
                if ('active' in e) {
                    if (!e.active) return !1;
                } else if ('ended' in e && e.ended) return !1;
                return !0;
            }
            function h(e, t) {
                function i(e, t) {
                    var i,
                        o = e.numberOfAudioChannels,
                        r = e.leftBuffers.slice(0),
                        A = e.rightBuffers.slice(0),
                        s = e.sampleRate,
                        n = e.internalInterleavedLength,
                        a = e.desiredSampRate;
                    function d(e, t, i) {
                        var o = Math.round(e.length * (t / i)),
                            r = [],
                            A = Number((e.length - 1) / (o - 1));
                        r[0] = e[0];
                        for (var s = 1; s < o - 1; s++) {
                            var n = s * A,
                                a = Number(Math.floor(n)).toFixed(),
                                d = Number(Math.ceil(n)).toFixed(),
                                l = n - a;
                            r[s] = c(e[a], e[d], l);
                        }
                        return (r[o - 1] = e[e.length - 1]), r;
                    }
                    function c(e, t, i) {
                        return e + (t - e) * i;
                    }
                    function l(e, t) {
                        for (
                            var i = new Float64Array(t),
                                o = 0,
                                r = e.length,
                                A = 0;
                            A < r;
                            A++
                        ) {
                            var s = e[A];
                            i.set(s, o), (o += s.length);
                        }
                        return i;
                    }
                    function u(e, t, i) {
                        for (var o = i.length, r = 0; r < o; r++)
                            e.setUint8(t + r, i.charCodeAt(r));
                    }
                    2 === o &&
                        ((r = l(r, n)),
                        (A = l(A, n)),
                        a && ((r = d(r, a, s)), (A = d(A, a, s)))),
                        1 === o && ((r = l(r, n)), a && (r = d(r, a, s))),
                        a && (s = a),
                        2 === o &&
                            (i = (function (e, t) {
                                for (
                                    var i = e.length + t.length,
                                        o = new Float64Array(i),
                                        r = 0,
                                        A = 0;
                                    A < i;

                                )
                                    (o[A++] = e[r]), (o[A++] = t[r]), r++;
                                return o;
                            })(r, A)),
                        1 === o && (i = r);
                    var h = i.length,
                        p = new ArrayBuffer(44 + 2 * h),
                        m = new DataView(p);
                    u(m, 0, 'RIFF'),
                        m.setUint32(4, 36 + 2 * h, !0),
                        u(m, 8, 'WAVE'),
                        u(m, 12, 'fmt '),
                        m.setUint32(16, 16, !0),
                        m.setUint16(20, 1, !0),
                        m.setUint16(22, o, !0),
                        m.setUint32(24, s, !0),
                        m.setUint32(28, s * o * 2, !0),
                        m.setUint16(32, 2 * o, !0),
                        m.setUint16(34, 16, !0),
                        u(m, 36, 'data'),
                        m.setUint32(40, 2 * h, !0);
                    for (var g = h, f = 44, b = 0; b < g; b++)
                        m.setInt16(f, 32767 * i[b], !0), (f += 2);
                    if (t) return t({ buffer: p, view: m });
                    postMessage({ buffer: p, view: m });
                }
                if (e.noWorker)
                    i(e, function (e) {
                        t(e.buffer, e.view);
                    });
                else {
                    var o,
                        r,
                        A,
                        s =
                            ((o = i),
                            (r = c.createObjectURL(
                                new Blob(
                                    [
                                        o.toString(),
                                        ';this.onmessage =  function (eee) {' +
                                            o.name +
                                            '(eee.data);}',
                                    ],
                                    { type: 'application/javascript' }
                                )
                            )),
                            ((A = new Worker(r)).workerURL = r),
                            A);
                    (s.onmessage = function (e) {
                        t(e.data.buffer, e.data.view),
                            c.revokeObjectURL(s.workerURL),
                            s.terminate();
                    }),
                        s.postMessage(e);
                }
            }
            !0 === i.leftChannel && (d = 1),
                1 === i.numberOfAudioChannels && (d = 1),
                (!d || d < 1) && (d = 2),
                i.disableLogs ||
                    console.log(
                        'StereoAudioRecorder is set to record number of channels: ' +
                            d
                    ),
                void 0 === i.checkForInactiveTracks &&
                    (i.checkForInactiveTracks = !0),
                (this.record = function () {
                    if (!1 === u())
                        throw 'Please make sure MediaStream is active.';
                    w(), (E = y = !1), (n = !0), void 0 !== i.timeSlice && C();
                }),
                (this.stop = function (e) {
                    (e = e || function () {}),
                        (n = !1),
                        h(
                            {
                                desiredSampRate: l,
                                sampleRate: b,
                                numberOfAudioChannels: d,
                                internalInterleavedLength: a,
                                leftBuffers: A,
                                rightBuffers: 1 === d ? [] : s,
                                noWorker: i.noWorker,
                            },
                            function (t, i) {
                                (r.blob = new Blob([i], { type: 'audio/wav' })),
                                    (r.buffer = new ArrayBuffer(
                                        i.buffer.byteLength
                                    )),
                                    (r.view = i),
                                    (r.sampleRate = l || b),
                                    (r.bufferSize = f),
                                    (r.length = a),
                                    (E = !1),
                                    e && e(r.blob);
                            }
                        );
                }),
                void 0 === t.Storage &&
                    (t.Storage = {
                        AudioContextConstructor: null,
                        AudioContext:
                            window.AudioContext || window.webkitAudioContext,
                    }),
                (t.Storage.AudioContextConstructor &&
                    'closed' !== t.Storage.AudioContextConstructor.state) ||
                    (t.Storage.AudioContextConstructor =
                        new t.Storage.AudioContext());
            var p = t.Storage.AudioContextConstructor,
                m = p.createMediaStreamSource(e),
                g = [0, 256, 512, 1024, 2048, 4096, 8192, 16384],
                f = void 0 === i.bufferSize ? 4096 : i.bufferSize;
            if (
                (-1 === g.indexOf(f) &&
                    (i.disableLogs ||
                        console.log(
                            'Legal values for buffer-size are ' +
                                JSON.stringify(g, null, '\t')
                        )),
                p.createJavaScriptNode)
            )
                o = p.createJavaScriptNode(f, d, d);
            else {
                if (!p.createScriptProcessor)
                    throw 'WebAudio API has no support on this browser.';
                o = p.createScriptProcessor(f, d, d);
            }
            m.connect(o), i.bufferSize || (f = o.bufferSize);
            var b =
                void 0 !== i.sampleRate ? i.sampleRate : p.sampleRate || 44100;
            (b < 22050 || b > 96e3) &&
                (i.disableLogs ||
                    console.log(
                        'sample-rate must be under range 22050 and 96000.'
                    )),
                i.disableLogs ||
                    (i.desiredSampRate &&
                        console.log(
                            'Desired sample-rate: ' + i.desiredSampRate
                        ));
            var y = !1;
            function w() {
                (A = []),
                    (s = []),
                    (a = 0),
                    (E = !1),
                    (n = !1),
                    (y = !1),
                    (p = null),
                    (r.leftchannel = A),
                    (r.rightchannel = s),
                    (r.numberOfAudioChannels = d),
                    (r.desiredSampRate = l),
                    (r.sampleRate = b),
                    (r.recordingLength = a),
                    (B = { left: [], right: [], recordingLength: 0 });
            }
            function S() {
                o && ((o.onaudioprocess = null), o.disconnect(), (o = null)),
                    m && (m.disconnect(), (m = null)),
                    w();
            }
            (this.pause = function () {
                y = !0;
            }),
                (this.resume = function () {
                    if (!1 === u())
                        throw 'Please make sure MediaStream is active.';
                    if (!n)
                        return (
                            i.disableLogs ||
                                console.log(
                                    'Seems recording has been restarted.'
                                ),
                            void this.record()
                        );
                    y = !1;
                }),
                (this.clearRecordedData = function () {
                    (i.checkForInactiveTracks = !1), n && this.stop(S), S();
                }),
                (this.name = 'StereoAudioRecorder'),
                (this.toString = function () {
                    return this.name;
                });
            var E = !1;
            (o.onaudioprocess = function (e) {
                if (!y)
                    if (
                        (!1 === u() &&
                            (i.disableLogs ||
                                console.log('MediaStream seems stopped.'),
                            o.disconnect(),
                            (n = !1)),
                        n)
                    ) {
                        E ||
                            ((E = !0),
                            i.onAudioProcessStarted &&
                                i.onAudioProcessStarted(),
                            i.initCallback && i.initCallback());
                        var t = e.inputBuffer.getChannelData(0),
                            c = new Float32Array(t);
                        if ((A.push(c), 2 === d)) {
                            var l = e.inputBuffer.getChannelData(1),
                                h = new Float32Array(l);
                            s.push(h);
                        }
                        (a += f),
                            (r.recordingLength = a),
                            void 0 !== i.timeSlice &&
                                ((B.recordingLength += f),
                                B.left.push(c),
                                2 === d && B.right.push(h));
                    } else m && (m.disconnect(), (m = null));
            }),
                p.createMediaStreamDestination
                    ? o.connect(p.createMediaStreamDestination())
                    : o.connect(p.destination),
                (this.leftchannel = A),
                (this.rightchannel = s),
                (this.numberOfAudioChannels = d),
                (this.desiredSampRate = l),
                (this.sampleRate = b),
                (r.recordingLength = a);
            var B = { left: [], right: [], recordingLength: 0 };
            function C() {
                n &&
                    'function' == typeof i.ondataavailable &&
                    void 0 !== i.timeSlice &&
                    (B.left.length
                        ? (h(
                              {
                                  desiredSampRate: l,
                                  sampleRate: b,
                                  numberOfAudioChannels: d,
                                  internalInterleavedLength: B.recordingLength,
                                  leftBuffers: B.left,
                                  rightBuffers: 1 === d ? [] : B.right,
                              },
                              function (e, t) {
                                  var o = new Blob([t], { type: 'audio/wav' });
                                  i.ondataavailable(o),
                                      setTimeout(C, i.timeSlice);
                              }
                          ),
                          (B = { left: [], right: [], recordingLength: 0 }))
                        : setTimeout(C, i.timeSlice));
            }
        }
        function R(e, t) {
            if ('undefined' == typeof html2canvas)
                throw 'Please link: https://www.webrtc-experiment.com/screenshot.js';
            (t = t || {}).frameInterval || (t.frameInterval = 10);
            var i = !1;
            [
                'captureStream',
                'mozCaptureStream',
                'webkitCaptureStream',
            ].forEach(function (e) {
                e in document.createElement('canvas') && (i = !0);
            });
            var o,
                r,
                A,
                s = !(
                    (!window.webkitRTCPeerConnection &&
                        !window.webkitGetUserMedia) ||
                    !window.chrome
                ),
                n = 50,
                a = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
            if (
                (s && a && a[2] && (n = parseInt(a[2], 10)),
                s && n < 52 && (i = !1),
                t.useWhammyRecorder && (i = !1),
                i)
            )
                if (
                    (t.disableLogs ||
                        console.log(
                            'Your browser supports both MediRecorder API and canvas.captureStream!'
                        ),
                    e instanceof HTMLCanvasElement)
                )
                    o = e;
                else {
                    if (!(e instanceof CanvasRenderingContext2D))
                        throw 'Please pass either HTMLCanvasElement or CanvasRenderingContext2D.';
                    o = e.canvas;
                }
            else
                navigator.mozGetUserMedia &&
                    (t.disableLogs ||
                        console.error(
                            'Canvas recording is NOT supported in Firefox.'
                        ));
            (this.record = function () {
                if (((A = !0), i && !t.useWhammyRecorder)) {
                    var e;
                    'captureStream' in o
                        ? (e = o.captureStream(25))
                        : 'mozCaptureStream' in o
                        ? (e = o.mozCaptureStream(25))
                        : 'webkitCaptureStream' in o &&
                          (e = o.webkitCaptureStream(25));
                    try {
                        var s = new g();
                        s.addTrack(v(e, 'video')[0]), (e = s);
                    } catch (e) {}
                    if (!e) throw 'captureStream API are NOT available.';
                    (r = new B(e, {
                        mimeType: t.mimeType || 'video/webm',
                    })).record();
                } else (h.frames = []), (u = new Date().getTime()), l();
                t.initCallback && t.initCallback();
            }),
                (this.getWebPImages = function (i) {
                    if ('canvas' === e.nodeName.toLowerCase()) {
                        var o = h.frames.length;
                        h.frames.forEach(function (e, i) {
                            var r = o - i;
                            t.disableLogs ||
                                console.log(r + '/' + o + ' frames remaining'),
                                t.onEncodingCallback &&
                                    t.onEncodingCallback(r, o);
                            var A = e.image.toDataURL('image/webp', 1);
                            h.frames[i].image = A;
                        }),
                            t.disableLogs || console.log('Generating WebM'),
                            i();
                    } else i();
                }),
                (this.stop = function (e) {
                    A = !1;
                    var o = this;
                    i && r
                        ? r.stop(e)
                        : this.getWebPImages(function () {
                              h.compile(function (i) {
                                  t.disableLogs ||
                                      console.log('Recording finished!'),
                                      (o.blob = i),
                                      o.blob.forEach &&
                                          (o.blob = new Blob([], {
                                              type: 'video/webm',
                                          })),
                                      e && e(o.blob),
                                      (h.frames = []);
                              });
                          });
                });
            var d = !1;
            function c() {
                (h.frames = []), (A = !1), (d = !1);
            }
            function l() {
                if (d) return (u = new Date().getTime()), setTimeout(l, 500);
                if ('canvas' === e.nodeName.toLowerCase()) {
                    var i = new Date().getTime() - u;
                    return (
                        (u = new Date().getTime()),
                        h.frames.push({
                            image:
                                ((o = document.createElement('canvas')),
                                (r = o.getContext('2d')),
                                (o.width = e.width),
                                (o.height = e.height),
                                r.drawImage(e, 0, 0),
                                o),
                            duration: i,
                        }),
                        void (A && setTimeout(l, t.frameInterval))
                    );
                }
                var o, r;
                html2canvas(e, {
                    grabMouse:
                        void 0 === t.showMousePointer || t.showMousePointer,
                    onrendered: function (e) {
                        var i = new Date().getTime() - u;
                        if (!i) return setTimeout(l, t.frameInterval);
                        (u = new Date().getTime()),
                            h.frames.push({
                                image: e.toDataURL('image/webp', 1),
                                duration: i,
                            }),
                            A && setTimeout(l, t.frameInterval);
                    },
                });
            }
            (this.pause = function () {
                (d = !0), r instanceof B && r.pause();
            }),
                (this.resume = function () {
                    (d = !1), r instanceof B ? r.resume() : A || this.record();
                }),
                (this.clearRecordedData = function () {
                    A && this.stop(c), c();
                }),
                (this.name = 'CanvasRecorder'),
                (this.toString = function () {
                    return this.name;
                });
            var u = new Date().getTime(),
                h = new T.Video(100);
        }
        function k(e, t) {
            function i(e) {
                e = void 0 !== e ? e : 10;
                var t = new Date().getTime() - a;
                return t
                    ? A
                        ? ((a = new Date().getTime()), setTimeout(i, 100))
                        : ((a = new Date().getTime()),
                          n.paused && n.play(),
                          l.drawImage(n, 0, 0, c.width, c.height),
                          d.frames.push({
                              duration: t,
                              image: c.toDataURL('image/webp'),
                          }),
                          void (r || setTimeout(i, e, e)))
                    : setTimeout(i, e, e);
            }
            function o(e, t, i, o, r) {
                var A = document.createElement('canvas');
                (A.width = c.width), (A.height = c.height);
                var s,
                    n,
                    a,
                    d = A.getContext('2d'),
                    l = [],
                    u = -1 === t,
                    h = t && t > 0 && t <= e.length ? t : e.length,
                    p = 0,
                    m = 0,
                    g = 0,
                    f = Math.sqrt(
                        Math.pow(255, 2) + Math.pow(255, 2) + Math.pow(255, 2)
                    ),
                    b = i && i >= 0 && i <= 1 ? i : 0,
                    y = o && o >= 0 && o <= 1 ? o : 0,
                    v = !1;
                (n = -1),
                    (a = (s = {
                        length: h,
                        functionToLoop: function (t, i) {
                            var o,
                                r,
                                A,
                                s = function () {
                                    (!v && A - o <= A * y) ||
                                        (u && (v = !0), l.push(e[i])),
                                        t();
                                };
                            if (v) s();
                            else {
                                var n = new Image();
                                (n.onload = function () {
                                    d.drawImage(n, 0, 0, c.width, c.height);
                                    var e = d.getImageData(
                                        0,
                                        0,
                                        c.width,
                                        c.height
                                    );
                                    (o = 0),
                                        (r = e.data.length),
                                        (A = e.data.length / 4);
                                    for (var t = 0; t < r; t += 4) {
                                        var i = {
                                            r: e.data[t],
                                            g: e.data[t + 1],
                                            b: e.data[t + 2],
                                        };
                                        Math.sqrt(
                                            Math.pow(i.r - p, 2) +
                                                Math.pow(i.g - m, 2) +
                                                Math.pow(i.b - g, 2)
                                        ) <=
                                            f * b && o++;
                                    }
                                    s();
                                }),
                                    (n.src = e[i].image);
                            }
                        },
                        callback: function () {
                            (l = l.concat(e.slice(h))).length <= 0 &&
                                l.push(e[e.length - 1]),
                                r(l);
                        },
                    }).length),
                    (function e() {
                        ++n !== a
                            ? setTimeout(function () {
                                  s.functionToLoop(e, n);
                              }, 1)
                            : s.callback();
                    })();
            }
            (t = t || {}).frameInterval || (t.frameInterval = 10),
                t.disableLogs ||
                    console.log('Using frames-interval:', t.frameInterval),
                (this.record = function () {
                    t.width || (t.width = 320),
                        t.height || (t.height = 240),
                        t.video ||
                            (t.video = { width: t.width, height: t.height }),
                        t.canvas ||
                            (t.canvas = { width: t.width, height: t.height }),
                        (c.width = t.canvas.width || 320),
                        (c.height = t.canvas.height || 240),
                        (l = c.getContext('2d')),
                        t.video && t.video instanceof HTMLVideoElement
                            ? ((n = t.video.cloneNode()),
                              t.initCallback && t.initCallback())
                            : ((n = document.createElement('video')),
                              w(e, n),
                              (n.onloadedmetadata = function () {
                                  t.initCallback && t.initCallback();
                              }),
                              (n.width = t.video.width),
                              (n.height = t.video.height)),
                        (n.muted = !0),
                        n.play(),
                        (a = new Date().getTime()),
                        (d = new T.Video()),
                        t.disableLogs ||
                            (console.log(
                                'canvas resolutions',
                                c.width,
                                '*',
                                c.height
                            ),
                            console.log(
                                'video width/height',
                                n.width || c.width,
                                '*',
                                n.height || c.height
                            )),
                        i(t.frameInterval);
                });
            var r = !1;
            this.stop = function (e) {
                (e = e || function () {}), (r = !0);
                var i = this;
                setTimeout(function () {
                    o(d.frames, -1, null, null, function (o) {
                        (d.frames = o),
                            t.advertisement &&
                                t.advertisement.length &&
                                (d.frames = t.advertisement.concat(d.frames)),
                            d.compile(function (t) {
                                (i.blob = t),
                                    i.blob.forEach &&
                                        (i.blob = new Blob([], {
                                            type: 'video/webm',
                                        })),
                                    e && e(i.blob);
                            });
                    });
                }, 10);
            };
            var A = !1;
            function s() {
                (d.frames = []), (r = !0), (A = !1);
            }
            (this.pause = function () {
                A = !0;
            }),
                (this.resume = function () {
                    (A = !1), r && this.record();
                }),
                (this.clearRecordedData = function () {
                    r || this.stop(s), s();
                }),
                (this.name = 'WhammyRecorder'),
                (this.toString = function () {
                    return this.name;
                });
            var n,
                a,
                d,
                c = document.createElement('canvas'),
                l = c.getContext('2d');
        }
        void 0 !== d
            ? (S.AudioContext = d)
            : 'undefined' != typeof webkitAudioContext &&
              (S.AudioContext = webkitAudioContext),
            (t.Storage = S),
            (t.MediaStreamRecorder = B),
            (t.StereoAudioRecorder = C),
            (t.CanvasRecorder = R),
            (t.WhammyRecorder = k);
        var T = (function () {
            function e(e) {
                (this.frames = []),
                    (this.duration = e || 1),
                    (this.quality = 0.8);
            }
            function t(e) {
                function t(e, t, i) {
                    return [{ data: e, id: 231 }].concat(
                        i.map(function (e) {
                            var i = (function (e) {
                                var t = 0;
                                e.keyframe && (t |= 128);
                                e.invisible && (t |= 8);
                                e.lacing && (t |= e.lacing << 1);
                                e.discardable && (t |= 1);
                                if (e.trackNum > 127)
                                    throw 'TrackNumber > 127 not supported';
                                return (
                                    [
                                        128 | e.trackNum,
                                        e.timecode >> 8,
                                        255 & e.timecode,
                                        t,
                                    ]
                                        .map(function (e) {
                                            return String.fromCharCode(e);
                                        })
                                        .join('') + e.frame
                                );
                            })({
                                discardable: 0,
                                frame: e.data.slice(4),
                                invisible: 0,
                                keyframe: 1,
                                lacing: 0,
                                trackNum: 1,
                                timecode: Math.round(t),
                            });
                            return (t += e.duration), { data: i, id: 163 };
                        })
                    );
                }
                function i(e) {
                    for (var t = []; e > 0; ) t.push(255 & e), (e >>= 8);
                    return new Uint8Array(t.reverse());
                }
                function o(e) {
                    var t = [];
                    e =
                        (e.length % 8
                            ? new Array(9 - (e.length % 8)).join('0')
                            : '') + e;
                    for (var i = 0; i < e.length; i += 8)
                        t.push(parseInt(e.substr(i, 8), 2));
                    return new Uint8Array(t);
                }
                function r(e) {
                    for (var t = [], A = 0; A < e.length; A++) {
                        var s = e[A].data;
                        'object' == typeof s && (s = r(s)),
                            'number' == typeof s && (s = o(s.toString(2))),
                            'string' == typeof s &&
                                (s = new Uint8Array(
                                    s.split('').map(function (e) {
                                        return e.charCodeAt(0);
                                    })
                                ));
                        var n = s.size || s.byteLength || s.length,
                            a = Math.ceil(
                                Math.ceil(Math.log(n) / Math.log(2)) / 8
                            ),
                            d = n.toString(2),
                            c =
                                new Array(7 * a + 7 + 1 - d.length).join('0') +
                                d,
                            l = new Array(a).join('0') + '1' + c;
                        t.push(i(e[A].id)), t.push(o(l)), t.push(s);
                    }
                    return new Blob(t, { type: 'video/webm' });
                }
                function A(e, t) {
                    return parseInt(
                        e
                            .substr(t + 4, 4)
                            .split('')
                            .map(function (e) {
                                var t = e.charCodeAt(0).toString(2);
                                return (
                                    new Array(8 - t.length + 1).join('0') + t
                                );
                            })
                            .join(''),
                        2
                    );
                }
                function s(e) {
                    for (var t = 0, i = {}; t < e.length; ) {
                        var o = e.substr(t, 4),
                            r = A(e, t),
                            n = e.substr(t + 4 + 4, r);
                        (t += 8 + r),
                            (i[o] = i[o] || []),
                            'RIFF' === o || 'LIST' === o
                                ? i[o].push(s(n))
                                : i[o].push(n);
                    }
                    return i;
                }
                var n = new (function (e) {
                    var i = (function (e) {
                        if (!e[0])
                            return void postMessage({
                                error: 'Something went wrong. Maybe WebP format is not supported in the current browser.',
                            });
                        for (
                            var t = e[0].width,
                                i = e[0].height,
                                o = e[0].duration,
                                r = 1;
                            r < e.length;
                            r++
                        )
                            o += e[r].duration;
                        return { duration: o, width: t, height: i };
                    })(e);
                    if (!i) return [];
                    for (
                        var o,
                            A = [
                                {
                                    id: 440786851,
                                    data: [
                                        { data: 1, id: 17030 },
                                        { data: 1, id: 17143 },
                                        { data: 4, id: 17138 },
                                        { data: 8, id: 17139 },
                                        { data: 'webm', id: 17026 },
                                        { data: 2, id: 17031 },
                                        { data: 2, id: 17029 },
                                    ],
                                },
                                {
                                    id: 408125543,
                                    data: [
                                        {
                                            id: 357149030,
                                            data: [
                                                { data: 1e6, id: 2807729 },
                                                { data: 'whammy', id: 19840 },
                                                { data: 'whammy', id: 22337 },
                                                {
                                                    data:
                                                        ((o = i.duration),
                                                        [].slice
                                                            .call(
                                                                new Uint8Array(
                                                                    new Float64Array(
                                                                        [o]
                                                                    ).buffer
                                                                ),
                                                                0
                                                            )
                                                            .map(function (e) {
                                                                return String.fromCharCode(
                                                                    e
                                                                );
                                                            })
                                                            .reverse()
                                                            .join('')),
                                                    id: 17545,
                                                },
                                            ],
                                        },
                                        {
                                            id: 374648427,
                                            data: [
                                                {
                                                    id: 174,
                                                    data: [
                                                        { data: 1, id: 215 },
                                                        { data: 1, id: 29637 },
                                                        { data: 0, id: 156 },
                                                        {
                                                            data: 'und',
                                                            id: 2274716,
                                                        },
                                                        {
                                                            data: 'V_VP8',
                                                            id: 134,
                                                        },
                                                        {
                                                            data: 'VP8',
                                                            id: 2459272,
                                                        },
                                                        { data: 1, id: 131 },
                                                        {
                                                            id: 224,
                                                            data: [
                                                                {
                                                                    data: i.width,
                                                                    id: 176,
                                                                },
                                                                {
                                                                    data: i.height,
                                                                    id: 186,
                                                                },
                                                            ],
                                                        },
                                                    ],
                                                },
                                            ],
                                        },
                                    ],
                                },
                            ],
                            s = 0,
                            n = 0;
                        s < e.length;

                    ) {
                        var a = [],
                            d = 0;
                        do {
                            a.push(e[s]), (d += e[s].duration), s++;
                        } while (s < e.length && d < 3e4);
                        var c = { id: 524531317, data: t(n, 0, a) };
                        A[1].data.push(c), (n += d);
                    }
                    return r(A);
                })(
                    e.map(function (e) {
                        var t = (function (e) {
                            for (
                                var t = e.RIFF[0].WEBP[0],
                                    i = t.indexOf('*'),
                                    o = 0,
                                    r = [];
                                o < 4;
                                o++
                            )
                                r[o] = t.charCodeAt(i + 3 + o);
                            return {
                                width: 16383 & ((r[1] << 8) | r[0]),
                                height: 16383 & ((r[3] << 8) | r[2]),
                                data: t,
                                riff: e,
                            };
                        })(s(atob(e.image.slice(23))));
                        return (t.duration = e.duration), t;
                    })
                );
                postMessage(n);
            }
            return (
                (e.prototype.add = function (e, t) {
                    if (
                        ('canvas' in e && (e = e.canvas),
                        'toDataURL' in e &&
                            (e = e.toDataURL('image/webp', this.quality)),
                        !/^data:image\/webp;base64,/gi.test(e))
                    )
                        throw 'Input must be formatted properly as a base64 encoded DataURI of type image/webp';
                    this.frames.push({
                        image: e,
                        duration: t || this.duration,
                    });
                }),
                (e.prototype.compile = function (e) {
                    var i,
                        o,
                        r,
                        A =
                            ((i = t),
                            (o = c.createObjectURL(
                                new Blob(
                                    [
                                        i.toString(),
                                        'this.onmessage =  function (eee) {' +
                                            i.name +
                                            '(eee.data);}',
                                    ],
                                    { type: 'application/javascript' }
                                )
                            )),
                            (r = new Worker(o)),
                            c.revokeObjectURL(o),
                            r);
                    (A.onmessage = function (t) {
                        t.data.error ? console.error(t.data.error) : e(t.data);
                    }),
                        A.postMessage(this.frames);
                }),
                { Video: e }
            );
        })();
        t.Whammy = T;
        var I = {
            init: function () {
                var e = this;
                if (
                    'undefined' != typeof indexedDB &&
                    void 0 !== indexedDB.open
                ) {
                    var t,
                        i =
                            this.dbName ||
                            location.href.replace(/\/|:|#|%|\.|\[|\]/g, ''),
                        o = indexedDB.open(i, 1);
                    (o.onerror = e.onError),
                        (o.onsuccess = function () {
                            (((t = o.result).onerror = e.onError), t.setVersion)
                                ? 1 !== t.version
                                    ? (t.setVersion(1).onsuccess = function () {
                                          r(t), A();
                                      })
                                    : A()
                                : A();
                        }),
                        (o.onupgradeneeded = function (e) {
                            r(e.target.result);
                        });
                } else
                    console.error(
                        'IndexedDB API are not available in this browser.'
                    );
                function r(t) {
                    t.createObjectStore(e.dataStoreName);
                }
                function A() {
                    var i = t.transaction([e.dataStoreName], 'readwrite');
                    function o(t) {
                        i.objectStore(e.dataStoreName).get(t).onsuccess =
                            function (i) {
                                e.callback && e.callback(i.target.result, t);
                            };
                    }
                    e.videoBlob &&
                        i
                            .objectStore(e.dataStoreName)
                            .put(e.videoBlob, 'videoBlob'),
                        e.gifBlob &&
                            i
                                .objectStore(e.dataStoreName)
                                .put(e.gifBlob, 'gifBlob'),
                        e.audioBlob &&
                            i
                                .objectStore(e.dataStoreName)
                                .put(e.audioBlob, 'audioBlob'),
                        o('audioBlob'),
                        o('videoBlob'),
                        o('gifBlob');
                }
            },
            Fetch: function (e) {
                return (this.callback = e), this.init(), this;
            },
            Store: function (e) {
                return (
                    (this.audioBlob = e.audioBlob),
                    (this.videoBlob = e.videoBlob),
                    (this.gifBlob = e.gifBlob),
                    this.init(),
                    this
                );
            },
            onError: function (e) {
                console.error(JSON.stringify(e, null, '\t'));
            },
            dataStoreName: 'recordRTC',
            dbName: null,
        };
        function D(e, t) {
            if ('undefined' == typeof GIFEncoder) {
                var i = document.createElement('script');
                (i.src = 'https://www.webrtc-experiment.com/gif-recorder.js'),
                    (document.body || document.documentElement).appendChild(i);
            }
            t = t || {};
            var o =
                e instanceof CanvasRenderingContext2D ||
                e instanceof HTMLCanvasElement;
            (this.record = function () {
                'undefined' != typeof GIFEncoder && d
                    ? (o ||
                          (t.width || (t.width = c.offsetWidth || 320),
                          t.height || (t.height = c.offsetHeight || 240),
                          t.video ||
                              (t.video = { width: t.width, height: t.height }),
                          t.canvas ||
                              (t.canvas = { width: t.width, height: t.height }),
                          (A.width = t.canvas.width || 320),
                          (A.height = t.canvas.height || 240),
                          (c.width = t.video.width || 320),
                          (c.height = t.video.height || 240)),
                      (u = new GIFEncoder()).setRepeat(0),
                      u.setDelay(t.frameRate || 200),
                      u.setQuality(t.quality || 10),
                      u.start(),
                      'function' == typeof t.onGifRecordingStarted &&
                          t.onGifRecordingStarted(),
                      (h = s(function e(i) {
                          if (!0 !== p.clearedRecordedData) {
                              if (r)
                                  return setTimeout(function () {
                                      e(i);
                                  }, 100);
                              (h = s(e)),
                                  void 0 === typeof l && (l = i),
                                  i - l < 90 ||
                                      (!o && c.paused && c.play(),
                                      o ||
                                          n.drawImage(
                                              c,
                                              0,
                                              0,
                                              A.width,
                                              A.height
                                          ),
                                      t.onGifPreview &&
                                          t.onGifPreview(
                                              A.toDataURL('image/png')
                                          ),
                                      u.addFrame(n),
                                      (l = i));
                          }
                      })),
                      t.initCallback && t.initCallback())
                    : setTimeout(p.record, 1e3);
            }),
                (this.stop = function (e) {
                    (e = e || function () {}),
                        h && a(h),
                        (this.blob = new Blob(
                            [new Uint8Array(u.stream().bin)],
                            { type: 'image/gif' }
                        )),
                        e(this.blob),
                        (u.stream().bin = []);
                });
            var r = !1;
            (this.pause = function () {
                r = !0;
            }),
                (this.resume = function () {
                    r = !1;
                }),
                (this.clearRecordedData = function () {
                    (p.clearedRecordedData = !0), u && (u.stream().bin = []);
                }),
                (this.name = 'GifRecorder'),
                (this.toString = function () {
                    return this.name;
                });
            var A = document.createElement('canvas'),
                n = A.getContext('2d');
            o &&
                (e instanceof CanvasRenderingContext2D
                    ? (A = (n = e).canvas)
                    : e instanceof HTMLCanvasElement &&
                      ((n = e.getContext('2d')), (A = e)));
            var d = !0;
            if (!o) {
                var c = document.createElement('video');
                (c.muted = !0),
                    (c.autoplay = !0),
                    (c.playsInline = !0),
                    (d = !1),
                    (c.onloadedmetadata = function () {
                        d = !0;
                    }),
                    w(e, c),
                    c.play();
            }
            var l,
                u,
                h = null,
                p = this;
        }
        function x(e, t) {
            t = t || 'multi-streams-mixer';
            var i = [],
                o = !1,
                r = document.createElement('canvas'),
                A = r.getContext('2d');
            (r.style.opacity = 0),
                (r.style.position = 'absolute'),
                (r.style.zIndex = -1),
                (r.style.top = '-1000em'),
                (r.style.left = '-1000em'),
                (r.className = t),
                (document.body || document.documentElement).appendChild(r),
                (this.disableLogs = !1),
                (this.frameInterval = 10),
                (this.width = 360),
                (this.height = 240),
                (this.useGainNode = !0);
            var s = this,
                n = window.AudioContext;
            void 0 === n &&
                ('undefined' != typeof webkitAudioContext &&
                    (n = webkitAudioContext),
                'undefined' != typeof mozAudioContext && (n = mozAudioContext));
            var a = window.URL;
            void 0 === a && 'undefined' != typeof webkitURL && (a = webkitURL),
                'undefined' != typeof navigator &&
                    void 0 === navigator.getUserMedia &&
                    (void 0 !== navigator.webkitGetUserMedia &&
                        (navigator.getUserMedia = navigator.webkitGetUserMedia),
                    void 0 !== navigator.mozGetUserMedia &&
                        (navigator.getUserMedia = navigator.mozGetUserMedia));
            var d = window.MediaStream;
            void 0 === d &&
                'undefined' != typeof webkitMediaStream &&
                (d = webkitMediaStream),
                void 0 !== d &&
                    void 0 === d.prototype.stop &&
                    (d.prototype.stop = function () {
                        this.getTracks().forEach(function (e) {
                            e.stop();
                        });
                    });
            var c = {};
            function l() {
                if (!o) {
                    var e = i.length,
                        t = !1,
                        A = [];
                    if (
                        (i.forEach(function (e) {
                            e.stream || (e.stream = {}),
                                e.stream.fullcanvas ? (t = e) : A.push(e);
                        }),
                        t)
                    )
                        (r.width = t.stream.width),
                            (r.height = t.stream.height);
                    else if (A.length) {
                        r.width = e > 1 ? 2 * A[0].width : A[0].width;
                        var n = 1;
                        (3 !== e && 4 !== e) || (n = 2),
                            (5 !== e && 6 !== e) || (n = 3),
                            (7 !== e && 8 !== e) || (n = 4),
                            (9 !== e && 10 !== e) || (n = 5),
                            (r.height = A[0].height * n);
                    } else
                        (r.width = s.width || 360),
                            (r.height = s.height || 240);
                    t && t instanceof HTMLVideoElement && u(t),
                        A.forEach(function (e, t) {
                            u(e, t);
                        }),
                        setTimeout(l, s.frameInterval);
                }
            }
            function u(e, t) {
                if (!o) {
                    var i = 0,
                        r = 0,
                        s = e.width,
                        n = e.height;
                    1 === t && (i = e.width),
                        2 === t && (r = e.height),
                        3 === t && ((i = e.width), (r = e.height)),
                        4 === t && (r = 2 * e.height),
                        5 === t && ((i = e.width), (r = 2 * e.height)),
                        6 === t && (r = 3 * e.height),
                        7 === t && ((i = e.width), (r = 3 * e.height)),
                        void 0 !== e.stream.left && (i = e.stream.left),
                        void 0 !== e.stream.top && (r = e.stream.top),
                        void 0 !== e.stream.width && (s = e.stream.width),
                        void 0 !== e.stream.height && (n = e.stream.height),
                        A.drawImage(e, i, r, s, n),
                        'function' == typeof e.stream.onRender &&
                            e.stream.onRender(A, i, r, s, n, t);
                }
            }
            function h(e) {
                var i = document.createElement('video');
                return (
                    (function (e, t) {
                        'srcObject' in t
                            ? (t.srcObject = e)
                            : 'mozSrcObject' in t
                            ? (t.mozSrcObject = e)
                            : (t.srcObject = e);
                    })(e, i),
                    (i.className = t),
                    (i.muted = !0),
                    (i.volume = 0),
                    (i.width = e.width || s.width || 360),
                    (i.height = e.height || s.height || 240),
                    i.play(),
                    i
                );
            }
            function p(t) {
                (i = []),
                    (t = t || e).forEach(function (e) {
                        if (
                            e.getTracks().filter(function (e) {
                                return 'video' === e.kind;
                            }).length
                        ) {
                            var t = h(e);
                            (t.stream = e), i.push(t);
                        }
                    });
            }
            void 0 !== n
                ? (c.AudioContext = n)
                : 'undefined' != typeof webkitAudioContext &&
                  (c.AudioContext = webkitAudioContext),
                (this.startDrawingFrames = function () {
                    l();
                }),
                (this.appendStreams = function (t) {
                    if (!t) throw 'First parameter is required.';
                    t instanceof Array || (t = [t]),
                        t.forEach(function (t) {
                            var o = new d();
                            if (
                                t.getTracks().filter(function (e) {
                                    return 'video' === e.kind;
                                }).length
                            ) {
                                var r = h(t);
                                (r.stream = t),
                                    i.push(r),
                                    o.addTrack(
                                        t.getTracks().filter(function (e) {
                                            return 'video' === e.kind;
                                        })[0]
                                    );
                            }
                            if (
                                t.getTracks().filter(function (e) {
                                    return 'audio' === e.kind;
                                }).length
                            ) {
                                var A =
                                    s.audioContext.createMediaStreamSource(t);
                                (s.audioDestination =
                                    s.audioContext.createMediaStreamDestination()),
                                    A.connect(s.audioDestination),
                                    o.addTrack(
                                        s.audioDestination.stream
                                            .getTracks()
                                            .filter(function (e) {
                                                return 'audio' === e.kind;
                                            })[0]
                                    );
                            }
                            e.push(o);
                        });
                }),
                (this.releaseStreams = function () {
                    (i = []),
                        (o = !0),
                        s.gainNode &&
                            (s.gainNode.disconnect(), (s.gainNode = null)),
                        s.audioSources.length &&
                            (s.audioSources.forEach(function (e) {
                                e.disconnect();
                            }),
                            (s.audioSources = [])),
                        s.audioDestination &&
                            (s.audioDestination.disconnect(),
                            (s.audioDestination = null)),
                        s.audioContext && s.audioContext.close(),
                        (s.audioContext = null),
                        A.clearRect(0, 0, r.width, r.height),
                        r.stream && (r.stream.stop(), (r.stream = null));
                }),
                (this.resetVideoStreams = function (e) {
                    !e || e instanceof Array || (e = [e]), p(e);
                }),
                (this.name = 'MultiStreamsMixer'),
                (this.toString = function () {
                    return this.name;
                }),
                (this.getMixedStream = function () {
                    o = !1;
                    var t = (function () {
                            var e;
                            p(),
                                'captureStream' in r
                                    ? (e = r.captureStream())
                                    : 'mozCaptureStream' in r
                                    ? (e = r.mozCaptureStream())
                                    : s.disableLogs ||
                                      console.error(
                                          'Upgrade to latest Chrome or otherwise enable this flag: chrome://flags/#enable-experimental-web-platform-features'
                                      );
                            var t = new d();
                            return (
                                e
                                    .getTracks()
                                    .filter(function (e) {
                                        return 'video' === e.kind;
                                    })
                                    .forEach(function (e) {
                                        t.addTrack(e);
                                    }),
                                (r.stream = t),
                                t
                            );
                        })(),
                        i = (function () {
                            c.AudioContextConstructor ||
                                (c.AudioContextConstructor =
                                    new c.AudioContext());
                            (s.audioContext = c.AudioContextConstructor),
                                (s.audioSources = []),
                                !0 === s.useGainNode &&
                                    ((s.gainNode = s.audioContext.createGain()),
                                    s.gainNode.connect(
                                        s.audioContext.destination
                                    ),
                                    (s.gainNode.gain.value = 0));
                            var t = 0;
                            if (
                                (e.forEach(function (e) {
                                    if (
                                        e.getTracks().filter(function (e) {
                                            return 'audio' === e.kind;
                                        }).length
                                    ) {
                                        t++;
                                        var i =
                                            s.audioContext.createMediaStreamSource(
                                                e
                                            );
                                        !0 === s.useGainNode &&
                                            i.connect(s.gainNode),
                                            s.audioSources.push(i);
                                    }
                                }),
                                !t)
                            )
                                return;
                            return (
                                (s.audioDestination =
                                    s.audioContext.createMediaStreamDestination()),
                                s.audioSources.forEach(function (e) {
                                    e.connect(s.audioDestination);
                                }),
                                s.audioDestination.stream
                            );
                        })();
                    return (
                        i &&
                            i
                                .getTracks()
                                .filter(function (e) {
                                    return 'audio' === e.kind;
                                })
                                .forEach(function (e) {
                                    t.addTrack(e);
                                }),
                        e.forEach(function (e) {
                            e.fullcanvas;
                        }),
                        t
                    );
                });
        }
        function L(e, t) {
            e = e || [];
            var i,
                o,
                r = this;
            (t = t || {
                elementClass: 'multi-streams-mixer',
                mimeType: 'video/webm',
                video: { width: 360, height: 240 },
            }).frameInterval || (t.frameInterval = 10),
                t.video || (t.video = {}),
                t.video.width || (t.video.width = 360),
                t.video.height || (t.video.height = 240),
                (this.record = function () {
                    var r;
                    (i = new x(e, t.elementClass || 'multi-streams-mixer')),
                        ((r = []),
                        e.forEach(function (e) {
                            v(e, 'video').forEach(function (e) {
                                r.push(e);
                            });
                        }),
                        r).length &&
                            ((i.frameInterval = t.frameInterval || 10),
                            (i.width = t.video.width || 360),
                            (i.height = t.video.height || 240),
                            i.startDrawingFrames()),
                        t.previewStream &&
                            'function' == typeof t.previewStream &&
                            t.previewStream(i.getMixedStream()),
                        (o = new B(i.getMixedStream(), t)).record();
                }),
                (this.stop = function (e) {
                    o &&
                        o.stop(function (t) {
                            (r.blob = t), e(t), r.clearRecordedData();
                        });
                }),
                (this.pause = function () {
                    o && o.pause();
                }),
                (this.resume = function () {
                    o && o.resume();
                }),
                (this.clearRecordedData = function () {
                    o && (o.clearRecordedData(), (o = null)),
                        i && (i.releaseStreams(), (i = null));
                }),
                (this.addStreams = function (r) {
                    if (!r) throw 'First parameter is required.';
                    r instanceof Array || (r = [r]),
                        e.concat(r),
                        o &&
                            i &&
                            (i.appendStreams(r),
                            t.previewStream &&
                                'function' == typeof t.previewStream &&
                                t.previewStream(i.getMixedStream()));
                }),
                (this.resetVideoStreams = function (e) {
                    i &&
                        (!e || e instanceof Array || (e = [e]),
                        i.resetVideoStreams(e));
                }),
                (this.getMixer = function () {
                    return i;
                }),
                (this.name = 'MultiStreamRecorder'),
                (this.toString = function () {
                    return this.name;
                });
        }
        function j(e, t) {
            var i, o, r;
            function A() {
                return new ReadableStream({
                    start: function (o) {
                        var r = document.createElement('canvas'),
                            A = document.createElement('video'),
                            s = !0;
                        (A.srcObject = e),
                            (A.muted = !0),
                            (A.height = t.height),
                            (A.width = t.width),
                            (A.volume = 0),
                            (A.onplaying = function () {
                                (r.width = t.width), (r.height = t.height);
                                var e = r.getContext('2d'),
                                    n = 1e3 / t.frameRate,
                                    a = setInterval(function () {
                                        if (
                                            (i && (clearInterval(a), o.close()),
                                            s &&
                                                ((s = !1),
                                                t.onVideoProcessStarted &&
                                                    t.onVideoProcessStarted()),
                                            e.drawImage(A, 0, 0),
                                            'closed' !==
                                                o._controlledReadableStream
                                                    .state)
                                        )
                                            try {
                                                o.enqueue(
                                                    e.getImageData(
                                                        0,
                                                        0,
                                                        t.width,
                                                        t.height
                                                    )
                                                );
                                            } catch (e) {}
                                    }, n);
                            }),
                            A.play();
                    },
                });
            }
            function s(e, a) {
                if (!t.workerPath && !a)
                    return (
                        (i = !1),
                        void fetch(
                            'https://unpkg.com/webm-wasm@latest/dist/webm-worker.js'
                        ).then(function (t) {
                            t.arrayBuffer().then(function (t) {
                                s(e, t);
                            });
                        })
                    );
                if (!t.workerPath && a instanceof ArrayBuffer) {
                    var d = new Blob([a], { type: 'text/javascript' });
                    t.workerPath = c.createObjectURL(d);
                }
                t.workerPath ||
                    console.error('workerPath parameter is missing.'),
                    (o = new Worker(t.workerPath)).postMessage(
                        t.webAssemblyPath ||
                            'https://unpkg.com/webm-wasm@latest/dist/webm-wasm.wasm'
                    ),
                    o.addEventListener('message', function (e) {
                        'READY' === e.data
                            ? (o.postMessage({
                                  width: t.width,
                                  height: t.height,
                                  bitrate: t.bitrate || 1200,
                                  timebaseDen: t.frameRate || 30,
                                  realtime: t.realtime,
                              }),
                              A().pipeTo(
                                  new WritableStream({
                                      write: function (e) {
                                          i
                                              ? console.error(
                                                    'Got image, but recorder is finished!'
                                                )
                                              : o.postMessage(e.data.buffer, [
                                                    e.data.buffer,
                                                ]);
                                      },
                                  })
                              ))
                            : e.data && (r || n.push(e.data));
                    });
            }
            ('undefined' != typeof ReadableStream &&
                'undefined' != typeof WritableStream) ||
                console.error(
                    'Following polyfill is strongly recommended: https://unpkg.com/@mattiasbuelens/web-streams-polyfill/dist/polyfill.min.js'
                ),
                ((t = t || {}).width = t.width || 640),
                (t.height = t.height || 480),
                (t.frameRate = t.frameRate || 30),
                (t.bitrate = t.bitrate || 1200),
                (t.realtime = t.realtime || !0),
                (this.record = function () {
                    (n = []),
                        (r = !1),
                        (this.blob = null),
                        s(e),
                        'function' == typeof t.initCallback && t.initCallback();
                }),
                (this.pause = function () {
                    r = !0;
                }),
                (this.resume = function () {
                    r = !1;
                });
            var n = [];
            (this.stop = function (e) {
                i = !0;
                var t = this;
                !(function (e) {
                    o
                        ? (o.addEventListener('message', function (t) {
                              null === t.data &&
                                  (o.terminate(), (o = null), e && e());
                          }),
                          o.postMessage(null))
                        : e && e();
                })(function () {
                    (t.blob = new Blob(n, { type: 'video/webm' })), e(t.blob);
                });
            }),
                (this.name = 'WebAssemblyRecorder'),
                (this.toString = function () {
                    return this.name;
                }),
                (this.clearRecordedData = function () {
                    (n = []), (r = !1), (this.blob = null);
                }),
                (this.blob = null);
        }
        (t.DiskStorage = I),
            (t.GifRecorder = D),
            (t.MultiStreamRecorder = L),
            (t.RecordRTCPromisesHandler = function (e, i) {
                if (!this) throw 'Use "new RecordRTCPromisesHandler()"';
                if (void 0 === e)
                    throw 'First argument "MediaStream" is required.';
                var o = this;
                (o.recordRTC = new t(e, i)),
                    (this.startRecording = function () {
                        return new Promise(function (e, t) {
                            try {
                                o.recordRTC.startRecording(), e();
                            } catch (e) {
                                t(e);
                            }
                        });
                    }),
                    (this.stopRecording = function () {
                        return new Promise(function (e, t) {
                            try {
                                o.recordRTC.stopRecording(function (i) {
                                    (o.blob = o.recordRTC.getBlob()),
                                        o.blob && o.blob.size
                                            ? e(i)
                                            : t('Empty blob.', o.blob);
                                });
                            } catch (e) {
                                t(e);
                            }
                        });
                    }),
                    (this.pauseRecording = function () {
                        return new Promise(function (e, t) {
                            try {
                                o.recordRTC.pauseRecording(), e();
                            } catch (e) {
                                t(e);
                            }
                        });
                    }),
                    (this.resumeRecording = function () {
                        return new Promise(function (e, t) {
                            try {
                                o.recordRTC.resumeRecording(), e();
                            } catch (e) {
                                t(e);
                            }
                        });
                    }),
                    (this.getDataURL = function (e) {
                        return new Promise(function (e, t) {
                            try {
                                o.recordRTC.getDataURL(function (t) {
                                    e(t);
                                });
                            } catch (e) {
                                t(e);
                            }
                        });
                    }),
                    (this.getBlob = function () {
                        return new Promise(function (e, t) {
                            try {
                                e(o.recordRTC.getBlob());
                            } catch (e) {
                                t(e);
                            }
                        });
                    }),
                    (this.getInternalRecorder = function () {
                        return new Promise(function (e, t) {
                            try {
                                e(o.recordRTC.getInternalRecorder());
                            } catch (e) {
                                t(e);
                            }
                        });
                    }),
                    (this.reset = function () {
                        return new Promise(function (e, t) {
                            try {
                                e(o.recordRTC.reset());
                            } catch (e) {
                                t(e);
                            }
                        });
                    }),
                    (this.destroy = function () {
                        return new Promise(function (e, t) {
                            try {
                                e(o.recordRTC.destroy());
                            } catch (e) {
                                t(e);
                            }
                        });
                    }),
                    (this.getState = function () {
                        return new Promise(function (e, t) {
                            try {
                                e(o.recordRTC.getState());
                            } catch (e) {
                                t(e);
                            }
                        });
                    }),
                    (this.blob = null),
                    (this.version = '5.6.2');
            }),
            (t.WebAssemblyRecorder = j);
    });
    class xe extends ve {
        constructor(e) {
            super(),
                (this.player = e),
                (this.fileName = ''),
                (this.fileType = J),
                (this.isRecording = !1),
                (this.recordingTimestamp = 0),
                (this.recordingInterval = null),
                e.debug.log('Recorder', 'init');
        }
        destroy() {
            this._reset(), this.player.debug.log('Recorder', 'destroy');
        }
        setFileName(e, t) {
            (this.fileName = e), (G !== t && J !== t) || (this.fileType = t);
        }
        get recording() {
            return this.isRecording;
        }
        get recordTime() {
            return this.recordingTimestamp;
        }
        startRecord() {
            const e = this.player.debug,
                t = {
                    type: 'video',
                    mimeType: 'video/webm;codecs=h264',
                    onTimeStamp: (t) => {
                        e.log('Recorder', 'record timestamp :' + t);
                    },
                    disableLogs: !this.player._opt.debug,
                };
            try {
                const e = this.player.video.$videoElement.captureStream(25);
                if (
                    this.player.audio &&
                    this.player.audio.mediaStreamAudioDestinationNode &&
                    this.player.audio.mediaStreamAudioDestinationNode.stream &&
                    !this.player.audio.isStateSuspended() &&
                    this.player.audio.hasAudio &&
                    this.player._opt.hasAudio
                ) {
                    const t =
                        this.player.audio.mediaStreamAudioDestinationNode
                            .stream;
                    if (t.getAudioTracks().length > 0) {
                        const i = t.getAudioTracks()[0];
                        i && i.enabled && e.addTrack(i);
                    }
                }
                this.recorder = De(e, t);
            } catch (t) {
                e.error('Recorder', t), this.emit(E.recordCreateError);
            }
            this.recorder &&
                ((this.isRecording = !0),
                this.emit(E.recording, !0),
                this.recorder.startRecording(),
                e.log('Recorder', 'start recording'),
                this.player.emit(E.recordStart),
                (this.recordingInterval = window.setInterval(() => {
                    (this.recordingTimestamp += 1),
                        this.player.emit(
                            E.recordingTimestamp,
                            this.recordingTimestamp
                        );
                }, 1e3)));
        }
        stopRecordAndSave() {
            this.recorder &&
                this.isRecording &&
                this.recorder.stopRecording(() => {
                    this.player.debug.log('Recorder', 'stop recording'),
                        this.player.emit(E.recordEnd),
                        (function (e, t, i) {
                            const o = window.URL.createObjectURL(e),
                                r = document.createElement('a');
                            (r.href = o),
                                (r.download =
                                    (t || ce()) +
                                    '.' +
                                    (i || FILE_SUFFIX.webm)),
                                r.click(),
                                setTimeout(
                                    () => {
                                        window.URL.revokeObjectURL(o);
                                    },
                                    ge() ? 1e3 : 0
                                );
                        })(
                            this.recorder.getBlob(),
                            this.fileName,
                            this.fileType
                        ),
                        this._reset(),
                        this.emit(E.recording, !1);
                });
        }
        _reset() {
            (this.isRecording = !1),
                (this.recordingTimestamp = 0),
                this.recorder &&
                    (this.recorder.destroy(), (this.recorder = null)),
                (this.fileName = null),
                this.recordingInterval && clearInterval(this.recordingInterval),
                (this.recordingInterval = null);
        }
    }
    class Le {
        constructor(e) {
            return new (Le.getLoaderFactory())(e);
        }
        static getLoaderFactory() {
            return xe;
        }
    }
    class je {
        constructor(e) {
            (this.player = e),
                (this.decoderWorker = new Worker(e._opt.decoder)),
                this._initDecoderWorker(),
                e.debug.log('decoderWorker', 'init');
        }
        destroy() {
            this.decoderWorker.postMessage({ cmd: w }),
                this.decoderWorker.terminate(),
                (this.decoderWorker = null),
                this.player.debug.log('decoderWorker', 'destroy');
        }
        _initDecoderWorker() {
            const {
                debug: e,
                events: { proxy: t },
            } = this.player;
            this.decoderWorker.onmessage = (t) => {
                const i = t.data;
                switch (i.cmd) {
                    case A:
                        e.log('decoderWorker', 'onmessage:', A),
                            this.player.loaded || this.player.emit(E.load),
                            this.player.emit(E.decoderWorkerInit),
                            this._initWork();
                        break;
                    case l:
                        e.log('decoderWorker', 'onmessage:', l, i.code),
                            this.player._times.decodeStart ||
                                (this.player._times.decodeStart = ce()),
                            this.player.video.updateVideoInfo({
                                encTypeCode: i.code,
                            });
                        break;
                    case c:
                        e.log('decoderWorker', 'onmessage:', c, i.code),
                            this.player.audio &&
                                this.player.audio.updateAudioInfo({
                                    encTypeCode: i.code,
                                });
                        break;
                    case s:
                        e.log(
                            'decoderWorker',
                            'onmessage:',
                            s,
                            `width:${i.w},height:${i.h}`
                        ),
                            this.player.video.updateVideoInfo({
                                width: i.w,
                                height: i.h,
                            }),
                            this.player.video.initCanvasViewSize();
                        break;
                    case d:
                        e.log(
                            'decoderWorker',
                            'onmessage:',
                            d,
                            `channels:${i.channels},sampleRate:${i.sampleRate}`
                        ),
                            this.player.audio &&
                                (this.player.audio.updateAudioInfo(i),
                                this.player.audio.initScriptNode(i));
                        break;
                    case n:
                        this.player.handleRender(),
                            this.player.video.render(i),
                            this.player.emit(E.timeUpdate, i.ts),
                            this.player.updateStats({
                                fps: !0,
                                ts: i.ts,
                                buf: i.delay,
                            }),
                            this.player._times.videoStart ||
                                ((this.player._times.videoStart = ce()),
                                this.player.handlePlayToRenderTimes());
                        break;
                    case a:
                        this.player.playing &&
                            this.player.audio &&
                            this.player.audio.play(i.buffer, i.ts);
                        break;
                    case u:
                        i.message &&
                            -1 !== i.message.indexOf(h) &&
                            (this.player.emit(E.error, C.wasmDecodeError),
                            this.player.emit(C.wasmDecodeError));
                        break;
                    default:
                        this.player[i.cmd] && this.player[i.cmd](i);
                }
            };
        }
        _initWork() {
            const e = {
                debug: this.player._opt.debug,
                forceNoOffscreen: this.player._opt.forceNoOffscreen,
                useWCS: this.player._opt.useWCS,
                videoBuffer: this.player._opt.videoBuffer,
            };
            this.decoderWorker.postMessage({
                cmd: b,
                opt: JSON.stringify(e),
                sampleRate:
                    (this.player.audio &&
                        this.player.audio.audioContext.sampleRate) ||
                    0,
            });
        }
        decodeVideo(e, t, i) {
            const o = { type: m, ts: Math.max(t, 0), isIFrame: i };
            this.decoderWorker.postMessage({ cmd: y, buffer: e, options: o }, [
                e.buffer,
            ]);
        }
        decodeAudio(e, t) {
            (this.player._opt.useWCS && !this.player._opt.useOffscreen) ||
            this.player._opt.useMSE
                ? this._decodeAudioNoDelay(e, t)
                : this._decodeAudio(e, t);
        }
        _decodeAudio(e, t) {
            const i = { type: p, ts: Math.max(t, 0) };
            this.decoderWorker.postMessage({ cmd: y, buffer: e, options: i }, [
                e.buffer,
            ]);
        }
        _decodeAudioNoDelay(e, t) {
            this.decoderWorker.postMessage(
                { cmd: v, buffer: e, ts: Math.max(t, 0) },
                [e.buffer]
            );
        }
        updateWorkConfig(e) {
            this.decoderWorker.postMessage({
                cmd: S,
                key: e.key,
                value: e.value,
            });
        }
    }
    class Ue extends ve {
        constructor(e) {
            super(),
                (this.player = e),
                (this.stopId = null),
                (this.firstTimestamp = null),
                (this.startTimestamp = null),
                (this.delay = -1),
                (this.bufferList = []),
                (this.dropping = !1),
                this.initInterval();
        }
        destroy() {
            this.stopId && (clearInterval(this.stopId), (this.stopId = null)),
                (this.firstTimestamp = null),
                (this.startTimestamp = null),
                (this.delay = -1),
                (this.bufferList = []),
                (this.dropping = !1),
                this.off();
        }
        getDelay(e) {
            return e
                ? (this.firstTimestamp
                      ? e &&
                        (this.delay =
                            Date.now() -
                            this.startTimestamp -
                            (e - this.firstTimestamp))
                      : ((this.firstTimestamp = e),
                        (this.startTimestamp = Date.now()),
                        (this.delay = -1)),
                  this.delay)
                : -1;
        }
        resetDelay() {
            (this.firstTimestamp = null),
                (this.startTimestamp = null),
                (this.delay = -1),
                (this.dropping = !1);
        }
        initInterval() {
            this.player.debug.log('common dumex', 'init Interval');
            let e = () => {
                let e;
                const t = this.player._opt.videoBuffer;
                if (this.bufferList.length)
                    if (this.dropping) {
                        for (
                            e = this.bufferList.shift(),
                                e.type === p &&
                                    0 === e.payload[1] &&
                                    this._doDecoderDecode(e);
                            !e.isIFrame && this.bufferList.length;

                        )
                            (e = this.bufferList.shift()),
                                e.type === p &&
                                    0 === e.payload[1] &&
                                    this._doDecoderDecode(e);
                        e.isIFrame &&
                            ((this.dropping = !1), this._doDecoderDecode(e));
                    } else if (
                        ((e = this.bufferList[0]), -1 === this.getDelay(e.ts))
                    )
                        this.bufferList.shift(), this._doDecoderDecode(e);
                    else if (this.delay > t + 1e3)
                        this.resetDelay(), (this.dropping = !0);
                    else
                        for (
                            ;
                            this.bufferList.length &&
                            ((e = this.bufferList[0]), this.getDelay(e.ts) > t);

                        )
                            this.bufferList.shift(), this._doDecoderDecode(e);
            };
            e(), (this.stopId = setInterval(e, 10));
        }
        _doDecode(e, t, i, o) {
            const r = this.player;
            let A = { ts: i, type: t, isIFrame: !1 };
            (r._opt.useWCS && !r._opt.useOffscreen) || r._opt.useMSE
                ? (t === m && (A.isIFrame = o), this.pushBuffer(e, A))
                : t === m
                ? r.decoderWorker && r.decoderWorker.decodeVideo(e, i, o)
                : t === p &&
                  r._opt.hasAudio &&
                  r.decoderWorker &&
                  r.decoderWorker.decodeAudio(e, i);
        }
        _doDecoderDecode(e) {
            const t = this.player,
                { webcodecsDecoder: i, mseDecoder: o } = t;
            e.type === p
                ? t._opt.hasAudio &&
                  t.decoderWorker &&
                  t.decoderWorker.decodeAudio(e.payload, e.ts)
                : e.type === m &&
                  (t._opt.useWCS && !t._opt.useOffscreen
                      ? i.decodeVideo(e.payload, e.ts, e.isIFrame)
                      : t._opt.useMSE &&
                        o.decodeVideo(e.payload, e.ts, e.isIFrame));
        }
        pushBuffer(e, t) {
            t.type === p
                ? this.bufferList.push({ ts: t.ts, payload: e, type: p })
                : t.type === m &&
                  this.bufferList.push({
                      ts: t.ts,
                      payload: e,
                      type: m,
                      isIFrame: t.isIFrame,
                  });
        }
        close() {}
    }
    class Fe extends Ue {
        constructor(e) {
            super(e),
                (this.input = this._inputFlv()),
                (this.flvDemux = this.dispatchFlvData(this.input)),
                e.debug.log('FlvDemux', 'init');
        }
        destroy() {
            super.destroy(),
                (this.input = null),
                (this.flvDemux = null),
                this.player.debug.log('FlvDemux', 'destroy');
        }
        dispatch(e) {
            this.flvDemux(e);
        }
        *_inputFlv() {
            yield 9;
            const e = new ArrayBuffer(4),
                t = new Uint8Array(e),
                i = new Uint32Array(e),
                o = this.player;
            for (;;) {
                t[3] = 0;
                const e = yield 15,
                    r = e[4];
                (t[0] = e[7]), (t[1] = e[6]), (t[2] = e[5]);
                const A = i[0];
                (t[0] = e[10]), (t[1] = e[9]), (t[2] = e[8]);
                let s = i[0];
                16777215 === s && ((t[3] = e[11]), (s = i[0]));
                const n = yield A;
                switch (r) {
                    case g:
                        o._opt.hasAudio &&
                            (o.updateStats({ abps: n.byteLength }),
                            n.byteLength > 0 && this._doDecode(n, p, s));
                        break;
                    case f:
                        if (
                            (o._times.demuxStart ||
                                (o._times.demuxStart = ce()),
                            o._opt.hasVideo)
                        ) {
                            o.updateStats({ vbps: n.byteLength });
                            const e = n[0] >> 4 == 1;
                            n.byteLength > 0 && this._doDecode(n, m, s, e);
                        }
                }
            }
        }
        dispatchFlvData(e) {
            let t = e.next(),
                i = null;
            return (o) => {
                let r = new Uint8Array(o);
                if (i) {
                    let e = new Uint8Array(i.length + r.length);
                    e.set(i), e.set(r, i.length), (r = e), (i = null);
                }
                for (; r.length >= t.value; ) {
                    let i = r.slice(t.value);
                    (t = e.next(r.slice(0, t.value))), (r = i);
                }
                r.length > 0 && (i = r);
            };
        }
        close() {
            this.input && this.input.return(null);
        }
    }
    class Ve extends Ue {
        constructor(e) {
            super(e), e.debug.log('M7sDemux', 'init');
        }
        destroy() {
            super.destroy(), this.player.debug.log('M7sDemux', 'destroy');
        }
        dispatch(e) {
            const t = this.player,
                i = new DataView(e),
                o = i.getUint8(0),
                r = i.getUint32(1, !1);
            switch (o) {
                case p:
                    if (t._opt.hasAudio) {
                        const i = new Uint8Array(e, 5);
                        t.updateStats({ abps: i.byteLength }),
                            i.byteLength > 0 && this._doDecode(i, o, r);
                    }
                    break;
                case m:
                    if (
                        t._opt.hasVideo &&
                        (t._times.demuxStart || (t._times.demuxStart = ce()),
                        i.byteLength > 5)
                    ) {
                        const A = new Uint8Array(e, 5),
                            s = i.getUint8(5) >> 4 == 1;
                        t.updateStats({ vbps: A.byteLength }),
                            A.byteLength > 0 && this._doDecode(A, o, r, s);
                    }
            }
        }
    }
    class Oe {
        constructor(e) {
            return new (Oe.getLoaderFactory(e._opt.demuxType))(e);
        }
        static getLoaderFactory(e) {
            return e === o ? Ve : e === i ? Fe : void 0;
        }
    }
    class Me extends ve {
        constructor(e) {
            super(),
                (this.player = e),
                (this.hasInit = !1),
                (this.isInitInfo = !1),
                (this.decoder = null),
                this.initDecoder(),
                e.debug.log('Webcodecs', 'init');
        }
        destroy() {
            this.decoder && (this.decoder.close(), (this.decoder = null)),
                (this.hasInit = !1),
                (this.isInitInfo = !1),
                this.off(),
                this.player.debug.log('Webcodecs', 'destroy');
        }
        initDecoder() {
            const e = this;
            this.decoder = new VideoDecoder({
                output(t) {
                    e.handleDecode(t);
                },
                error(t) {
                    e.handleError(t);
                },
            });
        }
        handleDecode(e) {
            this.isInitInfo ||
                (this.player.video.updateVideoInfo({
                    width: e.codedWidth,
                    height: e.codedHeight,
                }),
                this.player.video.initCanvasViewSize(),
                (this.isInitInfo = !0)),
                this.player._times.videoStart ||
                    ((this.player._times.videoStart = ce()),
                    this.player.handlePlayToRenderTimes()),
                this.player.handleRender(),
                this.player.video.render({ videoFrame: e }),
                this.player.updateStats({
                    fps: !0,
                    ts: 0,
                    buf: this.player.demux.delay,
                }),
                setTimeout(function () {
                    e.close ? e.close() : e.destroy();
                }, 100);
        }
        handleError(e) {
            this.player.debug.log('Webcodecs', 'VideoDecoder handleError', e);
        }
        decodeVideo(e, t, i) {
            if (this.hasInit) {
                const o = new EncodedVideoChunk({
                    data: e.slice(5),
                    timestamp: t,
                    type: i ? Y : H,
                });
                this.decoder.decode(o);
            } else if (i && 0 === e[1]) {
                const t = 15 & e[0];
                if (
                    (this.player.video.updateVideoInfo({ encTypeCode: t }),
                    t === j)
                )
                    return void this.emit(C.webcodecsH265NotSupport);
                this.player._times.decodeStart ||
                    (this.player._times.decodeStart = ce());
                const i = (function (e) {
                    let t = e.subarray(1, 4),
                        i = 'avc1.';
                    for (let e = 0; e < 3; e++) {
                        let o = t[e].toString(16);
                        o.length < 2 && (o = '0' + o), (i += o);
                    }
                    return { codec: i, description: e };
                })(e.slice(5));
                this.decoder.configure(i), (this.hasInit = !0);
            }
        }
    }
    const Qe = {
        play: '播放',
        pause: '暂停',
        audio: '',
        mute: '',
        screenshot: '截图',
        loading: '加载',
        fullscreen: '全屏',
        fullscreenExit: '退出全屏',
        record: '录制',
        recordStop: '停止录制',
    };
    var We = Object.keys(Qe).reduce(
            (e, t) => (
                (e[
                    t
                ] = `\n    <i class="jessibuca-icon jessibuca-icon-${t}"></i>\n    ${
                    Qe[t]
                        ? `<span class="icon-title-tips"><span class="icon-title">${Qe[t]}</span></span>`
                        : ''
                }\n`),
                e
            ),
            {}
        ),
        Ge = (e, t) => {
            const {
                    events: { proxy: i },
                } = e,
                o = document.createElement('object');
            o.setAttribute('aria-hidden', 'true'),
                o.setAttribute('tabindex', -1),
                (o.type = 'text/html'),
                (o.data = 'about:blank'),
                ue(o, {
                    display: 'block',
                    position: 'absolute',
                    top: '0',
                    left: '0',
                    height: '100%',
                    width: '100%',
                    overflow: 'hidden',
                    pointerEvents: 'none',
                    zIndex: '-1',
                });
            let r = e.width,
                A = e.height;
            i(o, 'load', () => {
                i(o.contentDocument.defaultView, 'resize', () => {
                    (e.width === r && e.height === A) ||
                        ((r = e.width), (A = e.height), e.emit(E.resize));
                });
            }),
                e.$container.appendChild(o),
                e.on(E.destroy, () => {
                    e.$container.removeChild(o);
                }),
                e.on(E.volumechange, () => {
                    !(function (e) {
                        if (0 === e)
                            ue(t.$volumeOn, 'display', 'none'),
                                ue(t.$volumeOff, 'display', 'flex'),
                                ue(t.$volumeHandle, 'top', '48px');
                        else if (t.$volumeHandle && t.$volumePanel) {
                            const i = he(t.$volumePanel, 'height') || 60,
                                o = he(t.$volumeHandle, 'height'),
                                r = i - (i - o) * e - o;
                            ue(t.$volumeHandle, 'top', `${r}px`),
                                ue(t.$volumeOn, 'display', 'flex'),
                                ue(t.$volumeOff, 'display', 'none');
                        }
                        t.$volumePanelText &&
                            (t.$volumePanelText.innerHTML = parseInt(100 * e));
                    })(e.volume);
                }),
                e.on(E.loading, (e) => {
                    ue(t.$loading, 'display', e ? 'flex' : 'none'),
                        ue(t.$poster, 'display', 'none'),
                        e && ue(t.$playBig, 'display', 'none');
                });
            try {
                const i = () => {
                    ue(
                        t.$fullscreenExit,
                        'display',
                        e.fullscreen ? 'flex' : 'none'
                    ),
                        ue(
                            t.$fullscreen,
                            'display',
                            e.fullscreen ? 'none' : 'flex'
                        );
                };
                se.on('change', i),
                    e.events.destroys.push(() => {
                        se.off('change', i);
                    });
            } catch (e) {}
            e.on(E.recording, () => {
                ue(t.$record, 'display', e.recording ? 'none' : 'flex'),
                    ue(t.$recordStop, 'display', e.recording ? 'flex' : 'none');
            }),
                e.on(E.recordingTimestamp, (e) => {}),
                e.on(E.playing, (e) => {
                    ue(t.$play, 'display', e ? 'none' : 'flex'),
                        ue(t.$playBig, 'display', e ? 'none' : 'block'),
                        ue(t.$pause, 'display', e ? 'flex' : 'none'),
                        ue(t.$screenshot, 'display', e ? 'flex' : 'none'),
                        ue(t.$record, 'display', e ? 'flex' : 'none'),
                        ue(t.$fullscreen, 'display', e ? 'flex' : 'none'),
                        e || (t.$speed && (t.$speed.innerHTML = fe('')));
                }),
                e.on(E.kBps, (e) => {
                    const i = fe(e);
                    t.$speed && (t.$speed.innerHTML = i);
                });
        };
    function Je(e, t) {
        void 0 === t && (t = {});
        var i = t.insertAt;
        if (e && 'undefined' != typeof document) {
            var o = document.head || document.getElementsByTagName('head')[0],
                r = document.createElement('style');
            (r.type = 'text/css'),
                'top' === i && o.firstChild
                    ? o.insertBefore(r, o.firstChild)
                    : o.appendChild(r),
                r.styleSheet
                    ? (r.styleSheet.cssText = e)
                    : r.appendChild(document.createTextNode(e));
        }
    }
    Je(
        '@keyframes rotation{0%{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(1turn)}}.jessibuca-container .jessibuca-icon{cursor:pointer;width:16px;height:16px}.jessibuca-container .jessibuca-poster{position:absolute;z-index:10;left:0;top:0;right:0;bottom:0;height:100%;width:100%;background-position:50%;background-repeat:no-repeat;background-size:contain;pointer-events:none}.jessibuca-container .jessibuca-play-big{position:absolute;display:none;height:100%;width:100%;background:rgba(0,0,0,.4);background-image:url("");background-repeat:no-repeat;background-position:50%;cursor:pointer;background-size:48px 48px}.jessibuca-container .jessibuca-play-big:hover{background-image:url("")}.jessibuca-container .jessibuca-loading{display:none;flex-direction:column;justify-content:center;align-items:center;position:absolute;z-index:20;left:0;top:0;right:0;bottom:0;width:100%;height:100%;pointer-events:none}.jessibuca-container .jessibuca-loading-text{line-height:20px;font-size:13px;color:#fff;margin-top:10px}.jessibuca-container .jessibuca-controls{background-color:#161616;display:flex;flex-direction:column;justify-content:flex-end;position:absolute;z-index:40;left:0;right:0;bottom:0;height:38px;padding-left:13px;padding-right:13px;font-size:14px;color:#fff;opacity:0;visibility:hidden;transition:all .2s ease-in-out;-webkit-user-select:none;user-select:none}.jessibuca-container .jessibuca-controls .jessibuca-controls-item{position:relative;display:flex;justify-content:center;padding:0 8px}.jessibuca-container .jessibuca-controls .jessibuca-controls-item:hover .icon-title-tips{visibility:visible;opacity:1}.jessibuca-container .jessibuca-controls .jessibuca-fullscreen,.jessibuca-container .jessibuca-controls .jessibuca-fullscreen-exit,.jessibuca-container .jessibuca-controls .jessibuca-icon-audio,.jessibuca-container .jessibuca-controls .jessibuca-microphone-close,.jessibuca-container .jessibuca-controls .jessibuca-pause,.jessibuca-container .jessibuca-controls .jessibuca-play,.jessibuca-container .jessibuca-controls .jessibuca-record,.jessibuca-container .jessibuca-controls .jessibuca-record-stop,.jessibuca-container .jessibuca-controls .jessibuca-screenshot{display:none}.jessibuca-container .jessibuca-controls .jessibuca-icon-audio,.jessibuca-container .jessibuca-controls .jessibuca-icon-mute{z-index:1}.jessibuca-container .jessibuca-controls .jessibuca-controls-bottom{display:flex;justify-content:space-between;height:100%}.jessibuca-container .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-left,.jessibuca-container .jessibuca-controls .jessibuca-controls-bottom .jessibuca-controls-right{display:flex;align-items:center}.jessibuca-container.jessibuca-controls-show .jessibuca-controls{opacity:1;visibility:visible}.jessibuca-container.jessibuca-hide-cursor *{cursor:none!important}.jessibuca-container.jessibuca-fullscreen-web{position:fixed;z-index:9999;left:0;top:0;right:0;bottom:0;width:100%!important;height:100%!important;background:#000}.jessibuca-container .jessibuca-icon-loading{width:50px;height:50px;background:url("") no-repeat 50%;background-size:100% 100%;animation:rotation 1s linear infinite}.jessibuca-container .jessibuca-icon-screenshot{background:url("") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-screenshot:hover{background:url("") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-play{background:url("") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-play:hover{background:url("") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-pause{background:url("") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-pause:hover{background:url("") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-record{background:url("") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-record:hover{background:url("") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-recordStop{background:url("") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-recordStop:hover{background:url("") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-fullscreen{background:url("") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-fullscreen:hover{background:url("") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-fullscreenExit{background:url("") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-fullscreenExit:hover{background:url("") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-audio{background:url("") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-audio:hover{background:url("") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-mute{background:url("") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-mute:hover{background:url("") no-repeat 50%;background-size:100% 100%}.jessibuca-container .jessibuca-icon-text{font-size:14px;width:30px}.jessibuca-container .jessibuca-speed{font-size:14px;color:#fff}.jessibuca-container .jessibuca-quality-menu-list{position:absolute;left:50%;bottom:100%;visibility:hidden;opacity:0;transform:translateX(-50%);transition:visibility .3s,opacity .3s;background-color:rgba(0,0,0,.5);border-radius:4px}.jessibuca-container .jessibuca-quality-menu-list.jessibuca-quality-menu-shown{visibility:visible;opacity:1}.jessibuca-container .icon-title-tips{pointer-events:none;position:absolute;left:50%;bottom:100%;visibility:hidden;opacity:0;transform:translateX(-50%);transition:visibility .3s ease 0s,opacity .3s ease 0s;background-color:rgba(0,0,0,.5);border-radius:4px}.jessibuca-container .icon-title{display:inline-block;padding:5px 10px;font-size:12px;white-space:nowrap;color:#fff}.jessibuca-container .jessibuca-quality-menu{padding:8px 0}.jessibuca-container .jessibuca-quality-menu-item{display:block;height:25px;margin:0;padding:0 10px;cursor:pointer;font-size:14px;text-align:center;width:50px;color:hsla(0,0%,100%,.5);transition:color .3s,background-color .3s}.jessibuca-container .jessibuca-quality-menu-item:hover{background-color:hsla(0,0%,100%,.2)}.jessibuca-container .jessibuca-quality-menu-item:focus{outline:none}.jessibuca-container .jessibuca-quality-menu-item.jessibuca-quality-menu-item-active{color:#2298fc}.jessibuca-container .jessibuca-volume-panel-wrap{position:absolute;left:50%;bottom:100%;visibility:hidden;opacity:0;transform:translateX(-50%) translateY(22%);transition:visibility .3s,opacity .3s;background-color:rgba(0,0,0,.5);border-radius:4px;height:120px;width:50px;overflow:hidden}.jessibuca-container .jessibuca-volume-panel-wrap.jessibuca-volume-panel-wrap-show{visibility:visible;opacity:1}.jessibuca-container .jessibuca-volume-panel{cursor:pointer;position:absolute;top:21px;height:60px;width:50px;overflow:hidden}.jessibuca-container .jessibuca-volume-panel-text{position:absolute;left:0;top:0;width:50px;height:20px;line-height:20px;text-align:center;color:#fff;font-size:12px}.jessibuca-container .jessibuca-volume-panel-handle{position:absolute;top:48px;left:50%;width:12px;height:12px;border-radius:12px;margin-left:-6px;background:#fff}.jessibuca-container .jessibuca-volume-panel-handle:before{bottom:-54px;background:#fff}.jessibuca-container .jessibuca-volume-panel-handle:after{bottom:6px;background:hsla(0,0%,100%,.2)}.jessibuca-container .jessibuca-volume-panel-handle:after,.jessibuca-container .jessibuca-volume-panel-handle:before{content:"";position:absolute;display:block;left:50%;width:3px;margin-left:-1px;height:60px}'
    );
    class Ne {
        constructor(e) {
            var t;
            (this.player = e),
                ((e, t) => {
                    e.$container.classList.add('jessibuca-controls-show');
                    const i = e._opt,
                        o = i.operateBtns;
                    e.$container.insertAdjacentHTML(
                        'beforeend',
                        `\n            ${
                            i.background
                                ? `<div class="jessibuca-poster" style="background-image: url(${i.background})"></div>`
                                : ''
                        }\n            <div class="jessibuca-loading">\n                ${
                            We.loading
                        }\n                ${
                            i.loadingText
                                ? `<div class="jessibuca-loading-text">${i.loadingText}</div>`
                                : ''
                        }\n            </div>\n            ${
                            i.hasControl && o.play
                                ? '<div class="jessibuca-play-big"></div>'
                                : ''
                        }\n            ${
                            i.hasControl
                                ? `\n                <div class="jessibuca-controls">\n                    <div class="jessibuca-controls-bottom">\n                        <div class="jessibuca-controls-left">\n                            ${
                                      i.showBandwidth
                                          ? '<div class="jessibuca-controls-item jessibuca-speed"></div>'
                                          : ''
                                  }\n                        </div>\n                        <div class="jessibuca-controls-right">\n                             ${
                                      o.audio
                                          ? `\n                                 <div class="jessibuca-controls-item jessibuca-volume">\n                                     ${We.audio}\n                                     ${We.mute}\n                                     <div class="jessibuca-volume-panel-wrap">\n                                          <div class="jessibuca-volume-panel">\n                                                 <div class="jessibuca-volume-panel-handle"></div>\n                                          </div>\n                                          <div class="jessibuca-volume-panel-text"></div>\n                                     </div>\n                                 </div>\n                             `
                                          : ''
                                  }\n                             ${
                                      o.play
                                          ? `<div class="jessibuca-controls-item jessibuca-play">${We.play}</div><div class="jessibuca-controls-item jessibuca-pause">${We.pause}</div>`
                                          : ''
                                  }\n                             ${
                                      o.screenshot
                                          ? `<div class="jessibuca-controls-item jessibuca-screenshot">${We.screenshot}</div>`
                                          : ''
                                  }\n                             ${
                                      o.record
                                          ? ` <div class="jessibuca-controls-item jessibuca-record">${We.record}</div><div class="jessibuca-controls-item jessibuca-record-stop">${We.recordStop}</div>`
                                          : ''
                                  }\n                             ${
                                      o.fullscreen
                                          ? `<div class="jessibuca-controls-item jessibuca-fullscreen">${We.fullscreen}</div><div class="jessibuca-controls-item jessibuca-fullscreen-exit">${We.fullscreenExit}</div>`
                                          : ''
                                  }\n                        </div>\n                    </div>\n                </div>\n            `
                                : ''
                        }\n\n        `
                    ),
                        Object.defineProperty(t, '$poster', {
                            value: e.$container.querySelector(
                                '.jessibuca-poster'
                            ),
                        }),
                        Object.defineProperty(t, '$loading', {
                            value: e.$container.querySelector(
                                '.jessibuca-loading'
                            ),
                        }),
                        Object.defineProperty(t, '$play', {
                            value: e.$container.querySelector(
                                '.jessibuca-play'
                            ),
                        }),
                        Object.defineProperty(t, '$playBig', {
                            value: e.$container.querySelector(
                                '.jessibuca-play-big'
                            ),
                        }),
                        Object.defineProperty(t, '$pause', {
                            value: e.$container.querySelector(
                                '.jessibuca-pause'
                            ),
                        }),
                        Object.defineProperty(t, '$controls', {
                            value: e.$container.querySelector(
                                '.jessibuca-controls'
                            ),
                        }),
                        Object.defineProperty(t, '$fullscreen', {
                            value: e.$container.querySelector(
                                '.jessibuca-fullscreen'
                            ),
                        }),
                        Object.defineProperty(t, '$fullscreen', {
                            value: e.$container.querySelector(
                                '.jessibuca-fullscreen'
                            ),
                        }),
                        Object.defineProperty(t, '$volume', {
                            value: e.$container.querySelector(
                                '.jessibuca-volume'
                            ),
                        }),
                        Object.defineProperty(t, '$volumePanelWrap', {
                            value: e.$container.querySelector(
                                '.jessibuca-volume-panel-wrap'
                            ),
                        }),
                        Object.defineProperty(t, '$volumePanelText', {
                            value: e.$container.querySelector(
                                '.jessibuca-volume-panel-text'
                            ),
                        }),
                        Object.defineProperty(t, '$volumePanel', {
                            value: e.$container.querySelector(
                                '.jessibuca-volume-panel'
                            ),
                        }),
                        Object.defineProperty(t, '$volumeHandle', {
                            value: e.$container.querySelector(
                                '.jessibuca-volume-panel-handle'
                            ),
                        }),
                        Object.defineProperty(t, '$volumeOn', {
                            value: e.$container.querySelector(
                                '.jessibuca-icon-audio'
                            ),
                        }),
                        Object.defineProperty(t, '$volumeOff', {
                            value: e.$container.querySelector(
                                '.jessibuca-icon-mute'
                            ),
                        }),
                        Object.defineProperty(t, '$fullscreen', {
                            value: e.$container.querySelector(
                                '.jessibuca-fullscreen'
                            ),
                        }),
                        Object.defineProperty(t, '$fullscreenExit', {
                            value: e.$container.querySelector(
                                '.jessibuca-fullscreen-exit'
                            ),
                        }),
                        Object.defineProperty(t, '$record', {
                            value: e.$container.querySelector(
                                '.jessibuca-record'
                            ),
                        }),
                        Object.defineProperty(t, '$recordStop', {
                            value: e.$container.querySelector(
                                '.jessibuca-record-stop'
                            ),
                        }),
                        Object.defineProperty(t, '$screenshot', {
                            value: e.$container.querySelector(
                                '.jessibuca-screenshot'
                            ),
                        }),
                        Object.defineProperty(t, '$speed', {
                            value: e.$container.querySelector(
                                '.jessibuca-speed'
                            ),
                        });
                })(e, this),
                Ge(e, this),
                (t = this),
                Object.defineProperty(t, 'controlsRect', {
                    get: () => t.$controls.getBoundingClientRect(),
                }),
                ((e, t) => {
                    const {
                        events: { proxy: i },
                        debug: o,
                    } = e;
                    function r(e) {
                        const { bottom: i, height: o } =
                                t.$volumePanel.getBoundingClientRect(),
                            { height: r } =
                                t.$volumeHandle.getBoundingClientRect();
                        return le(i - e.y - r / 2, 0, o - r / 2) / (o - r);
                    }
                    i(window, ['click', 'contextmenu'], (i) => {
                        i.composedPath().indexOf(e.$container) > -1
                            ? (t.isFocus = !0)
                            : (t.isFocus = !1);
                    }),
                        i(window, 'orientationchange', () => {
                            setTimeout(() => {
                                e.resize();
                            }, 300);
                        }),
                        i(t.$controls, 'click', (e) => {
                            e.stopPropagation();
                        }),
                        i(t.$pause, 'click', (t) => {
                            e.pause();
                        }),
                        i(t.$play, 'click', (t) => {
                            e.play();
                        }),
                        i(t.$playBig, 'click', (t) => {
                            e.play();
                        }),
                        i(t.$volume, 'mouseover', () => {
                            t.$volumePanelWrap.classList.add(
                                'jessibuca-volume-panel-wrap-show'
                            );
                        }),
                        i(t.$volume, 'mouseout', () => {
                            t.$volumePanelWrap.classList.remove(
                                'jessibuca-volume-panel-wrap-show'
                            );
                        }),
                        i(t.$volumeOn, 'click', (i) => {
                            i.stopPropagation(),
                                ue(t.$volumeOn, 'display', 'none'),
                                ue(t.$volumeOff, 'display', 'block'),
                                (e.lastVolume = e.volume),
                                (e.volume = 0);
                        }),
                        i(t.$volumeOff, 'click', (i) => {
                            i.stopPropagation(),
                                ue(t.$volumeOn, 'display', 'block'),
                                ue(t.$volumeOff, 'display', 'none'),
                                (e.volume = e.lastVolume || 0.5);
                        }),
                        i(t.$screenshot, 'click', (t) => {
                            t.stopPropagation(), e.video.screenshot();
                        }),
                        i(t.$volumePanel, 'click', (t) => {
                            t.stopPropagation(), (e.volume = r(t));
                        }),
                        i(t.$volumeHandle, 'mousedown', () => {
                            t.isVolumeDroging = !0;
                        }),
                        i(t.$volumeHandle, 'mousemove', (i) => {
                            t.isVolumeDroging && (e.volume = r(i));
                        }),
                        i(document, 'mouseup', () => {
                            t.isVolumeDroging && (t.isVolumeDroging = !1);
                        }),
                        i(t.$record, 'click', (t) => {
                            t.stopPropagation(), (e.recording = !0);
                        }),
                        i(t.$recordStop, 'click', (t) => {
                            t.stopPropagation(), (e.recording = !1);
                        }),
                        i(t.$fullscreen, 'click', (t) => {
                            t.stopPropagation(), (e.fullscreen = !0);
                        }),
                        i(t.$fullscreenExit, 'click', (t) => {
                            t.stopPropagation(), (e.fullscreen = !1);
                        });
                })(e, this),
                e._opt.hotKey &&
                    ((e, t) => {
                        const {
                                events: { proxy: i },
                            } = e,
                            o = {};
                        function r(e, t) {
                            o[e] ? o[e].push(t) : (o[e] = [t]);
                        }
                        r($, () => {
                            e.fullscreen && (e.fullscreen = !1);
                        }),
                            r(ee, () => {
                                e.volume += 0.05;
                            }),
                            r(te, () => {
                                e.volume -= 0.05;
                            }),
                            i(window, 'keydown', (e) => {
                                if (t.isFocus) {
                                    const t =
                                            document.activeElement.tagName.toUpperCase(),
                                        i =
                                            document.activeElement.getAttribute(
                                                'contenteditable'
                                            );
                                    if (
                                        'INPUT' !== t &&
                                        'TEXTAREA' !== t &&
                                        '' !== i &&
                                        'true' !== i
                                    ) {
                                        const t = o[e.keyCode];
                                        t &&
                                            (e.preventDefault(),
                                            t.forEach((e) => e()));
                                    }
                                }
                            });
                    })(e, this),
                this.player.debug.log('Control', 'init');
        }
        destroy() {
            this.$poster && this.player.$container.removeChild(this.$poster),
                this.$loading &&
                    this.player.$container.removeChild(this.$loading),
                this.$controls &&
                    this.player.$container.removeChild(this.$controls),
                this.$playBig &&
                    this.player.$container.removeChild(this.$playBig),
                this.player.debug.log('control', 'destroy');
        }
        autoSize() {
            const e = this.player;
            e.$container.style.padding = '0 0';
            const t = e.width,
                i = e.height,
                o = t / i,
                r = e.video.$videoElement.width / e.video.$videoElement.height;
            if (o > r) {
                const o = (t - i * r) / 2;
                e.$container.style.padding = `0 ${o}px`;
            } else {
                const o = (i - t / r) / 2;
                e.$container.style.padding = `${o}px 0`;
            }
        }
    }
    Je(
        '.jessibuca-container{position:relative;width:100%;height:100%;overflow:hidden}.jessibuca-container.jessibuca-fullscreen-web{position:fixed;z-index:9999;left:0;top:0;right:0;bottom:0;width:100%!important;height:100%!important;background:#000}'
    );
    class Pe {
        static init() {
            Pe.types = {
                avc1: [],
                avcC: [],
                hvc1: [],
                hvcC: [],
                btrt: [],
                dinf: [],
                dref: [],
                esds: [],
                ftyp: [],
                hdlr: [],
                mdat: [],
                mdhd: [],
                mdia: [],
                mfhd: [],
                minf: [],
                moof: [],
                moov: [],
                mp4a: [],
                mvex: [],
                mvhd: [],
                sdtp: [],
                stbl: [],
                stco: [],
                stsc: [],
                stsd: [],
                stsz: [],
                stts: [],
                tfdt: [],
                tfhd: [],
                traf: [],
                trak: [],
                trun: [],
                trex: [],
                tkhd: [],
                vmhd: [],
                smhd: [],
            };
            for (let e in Pe.types)
                Pe.types.hasOwnProperty(e) &&
                    (Pe.types[e] = [
                        e.charCodeAt(0),
                        e.charCodeAt(1),
                        e.charCodeAt(2),
                        e.charCodeAt(3),
                    ]);
            let e = (Pe.constants = {});
            (e.FTYP = new Uint8Array([
                105, 115, 111, 109, 0, 0, 0, 1, 105, 115, 111, 109, 97, 118, 99,
                49,
            ])),
                (e.STSD_PREFIX = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 1])),
                (e.STTS = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0])),
                (e.STSC = e.STCO = e.STTS),
                (e.STSZ = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])),
                (e.HDLR_VIDEO = new Uint8Array([
                    0, 0, 0, 0, 0, 0, 0, 0, 118, 105, 100, 101, 0, 0, 0, 0, 0,
                    0, 0, 0, 0, 0, 0, 0, 86, 105, 100, 101, 111, 72, 97, 110,
                    100, 108, 101, 114, 0,
                ])),
                (e.HDLR_AUDIO = new Uint8Array([
                    0, 0, 0, 0, 0, 0, 0, 0, 115, 111, 117, 110, 0, 0, 0, 0, 0,
                    0, 0, 0, 0, 0, 0, 0, 83, 111, 117, 110, 100, 72, 97, 110,
                    100, 108, 101, 114, 0,
                ])),
                (e.DREF = new Uint8Array([
                    0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 12, 117, 114, 108, 32, 0,
                    0, 0, 1,
                ])),
                (e.SMHD = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0])),
                (e.VMHD = new Uint8Array([0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]));
        }
        static box(e) {
            let t = 8,
                i = null,
                o = Array.prototype.slice.call(arguments, 1),
                r = o.length;
            for (let e = 0; e < r; e++) t += o[e].byteLength;
            (i = new Uint8Array(t)),
                (i[0] = (t >>> 24) & 255),
                (i[1] = (t >>> 16) & 255),
                (i[2] = (t >>> 8) & 255),
                (i[3] = 255 & t),
                i.set(e, 4);
            let A = 8;
            for (let e = 0; e < r; e++) i.set(o[e], A), (A += o[e].byteLength);
            return i;
        }
        static generateInitSegment(e) {
            let t = Pe.box(Pe.types.ftyp, Pe.constants.FTYP),
                i = Pe.moov(e),
                o = new Uint8Array(t.byteLength + i.byteLength);
            return o.set(t, 0), o.set(i, t.byteLength), o;
        }
        static moov(e) {
            let t = Pe.mvhd(e.timescale, e.duration),
                i = Pe.trak(e),
                o = Pe.mvex(e);
            return Pe.box(Pe.types.moov, t, i, o);
        }
        static mvhd(e, t) {
            return Pe.box(
                Pe.types.mvhd,
                new Uint8Array([
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    (e >>> 24) & 255,
                    (e >>> 16) & 255,
                    (e >>> 8) & 255,
                    255 & e,
                    (t >>> 24) & 255,
                    (t >>> 16) & 255,
                    (t >>> 8) & 255,
                    255 & t,
                    0,
                    1,
                    0,
                    0,
                    1,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    1,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    1,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    64,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    255,
                    255,
                    255,
                    255,
                ])
            );
        }
        static trak(e) {
            return Pe.box(Pe.types.trak, Pe.tkhd(e), Pe.mdia(e));
        }
        static tkhd(e) {
            let t = e.id,
                i = e.duration,
                o = e.presentWidth,
                r = e.presentHeight;
            return Pe.box(
                Pe.types.tkhd,
                new Uint8Array([
                    0,
                    0,
                    0,
                    7,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    (t >>> 24) & 255,
                    (t >>> 16) & 255,
                    (t >>> 8) & 255,
                    255 & t,
                    0,
                    0,
                    0,
                    0,
                    (i >>> 24) & 255,
                    (i >>> 16) & 255,
                    (i >>> 8) & 255,
                    255 & i,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    1,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    1,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    64,
                    0,
                    0,
                    0,
                    (o >>> 8) & 255,
                    255 & o,
                    0,
                    0,
                    (r >>> 8) & 255,
                    255 & r,
                    0,
                    0,
                ])
            );
        }
        static mdia(e) {
            return Pe.box(Pe.types.mdia, Pe.mdhd(e), Pe.hdlr(e), Pe.minf(e));
        }
        static mdhd(e) {
            let t = e.timescale,
                i = e.duration;
            return Pe.box(
                Pe.types.mdhd,
                new Uint8Array([
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    (t >>> 24) & 255,
                    (t >>> 16) & 255,
                    (t >>> 8) & 255,
                    255 & t,
                    (i >>> 24) & 255,
                    (i >>> 16) & 255,
                    (i >>> 8) & 255,
                    255 & i,
                    85,
                    196,
                    0,
                    0,
                ])
            );
        }
        static hdlr(e) {
            let t = null;
            return (
                (t =
                    'audio' === e.type
                        ? Pe.constants.HDLR_AUDIO
                        : Pe.constants.HDLR_VIDEO),
                Pe.box(Pe.types.hdlr, t)
            );
        }
        static minf(e) {
            let t = null;
            return (
                (t =
                    'audio' === e.type
                        ? Pe.box(Pe.types.smhd, Pe.constants.SMHD)
                        : Pe.box(Pe.types.vmhd, Pe.constants.VMHD)),
                Pe.box(Pe.types.minf, t, Pe.dinf(), Pe.stbl(e))
            );
        }
        static dinf() {
            return Pe.box(
                Pe.types.dinf,
                Pe.box(Pe.types.dref, Pe.constants.DREF)
            );
        }
        static stbl(e) {
            return Pe.box(
                Pe.types.stbl,
                Pe.stsd(e),
                Pe.box(Pe.types.stts, Pe.constants.STTS),
                Pe.box(Pe.types.stsc, Pe.constants.STSC),
                Pe.box(Pe.types.stsz, Pe.constants.STSZ),
                Pe.box(Pe.types.stco, Pe.constants.STCO)
            );
        }
        static stsd(e) {
            return 'audio' === e.type
                ? Pe.box(Pe.types.stsd, Pe.constants.STSD_PREFIX, Pe.mp4a(e))
                : 'avc' === e.videoType
                ? Pe.box(Pe.types.stsd, Pe.constants.STSD_PREFIX, Pe.avc1(e))
                : Pe.box(Pe.types.stsd, Pe.constants.STSD_PREFIX, Pe.hvc1(e));
        }
        static mp4a(e) {
            let t = e.channelCount,
                i = e.audioSampleRate,
                o = new Uint8Array([
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    1,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    t,
                    0,
                    16,
                    0,
                    0,
                    0,
                    0,
                    (i >>> 8) & 255,
                    255 & i,
                    0,
                    0,
                ]);
            return Pe.box(Pe.types.mp4a, o, Pe.esds(e));
        }
        static esds(e) {
            let t = e.config || [],
                i = t.length,
                o = new Uint8Array(
                    [
                        0,
                        0,
                        0,
                        0,
                        3,
                        23 + i,
                        0,
                        1,
                        0,
                        4,
                        15 + i,
                        64,
                        21,
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        0,
                        5,
                    ]
                        .concat([i])
                        .concat(t)
                        .concat([6, 1, 2])
                );
            return Pe.box(Pe.types.esds, o);
        }
        static avc1(e) {
            let t = e.avcc;
            const i = e.codecWidth,
                o = e.codecHeight;
            let r = new Uint8Array([
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                1,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                (i >>> 8) & 255,
                255 & i,
                (o >>> 8) & 255,
                255 & o,
                0,
                72,
                0,
                0,
                0,
                72,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                1,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                24,
                255,
                255,
            ]);
            return Pe.box(Pe.types.avc1, r, Pe.box(Pe.types.avcC, t));
        }
        static hvc1(e) {
            let t = e.avcc;
            const i = e.codecWidth,
                o = e.codecHeight;
            let r = new Uint8Array([
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                1,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                (i >>> 8) & 255,
                255 & i,
                (o >>> 8) & 255,
                255 & o,
                0,
                72,
                0,
                0,
                0,
                72,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                1,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                24,
                255,
                255,
            ]);
            return Pe.box(Pe.types.hvc1, r, Pe.box(Pe.types.hvcC, t));
        }
        static mvex(e) {
            return Pe.box(Pe.types.mvex, Pe.trex(e));
        }
        static trex(e) {
            let t = e.id,
                i = new Uint8Array([
                    0,
                    0,
                    0,
                    0,
                    (t >>> 24) & 255,
                    (t >>> 16) & 255,
                    (t >>> 8) & 255,
                    255 & t,
                    0,
                    0,
                    0,
                    1,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    0,
                    1,
                    0,
                    1,
                ]);
            return Pe.box(Pe.types.trex, i);
        }
        static moof(e, t) {
            return Pe.box(
                Pe.types.moof,
                Pe.mfhd(e.sequenceNumber),
                Pe.traf(e, t)
            );
        }
        static mfhd(e) {
            let t = new Uint8Array([
                0,
                0,
                0,
                0,
                (e >>> 24) & 255,
                (e >>> 16) & 255,
                (e >>> 8) & 255,
                255 & e,
            ]);
            return Pe.box(Pe.types.mfhd, t);
        }
        static traf(e, t) {
            let i = e.id,
                o = Pe.box(
                    Pe.types.tfhd,
                    new Uint8Array([
                        0,
                        0,
                        0,
                        0,
                        (i >>> 24) & 255,
                        (i >>> 16) & 255,
                        (i >>> 8) & 255,
                        255 & i,
                    ])
                ),
                r = Pe.box(
                    Pe.types.tfdt,
                    new Uint8Array([
                        0,
                        0,
                        0,
                        0,
                        (t >>> 24) & 255,
                        (t >>> 16) & 255,
                        (t >>> 8) & 255,
                        255 & t,
                    ])
                ),
                A = Pe.sdtp(e),
                s = Pe.trun(e, A.byteLength + 16 + 16 + 8 + 16 + 8 + 8);
            return Pe.box(Pe.types.traf, o, r, s, A);
        }
        static sdtp(e) {
            let t = new Uint8Array(5),
                i = e.flags;
            return (
                (t[4] =
                    (i.isLeading << 6) |
                    (i.dependsOn << 4) |
                    (i.isDependedOn << 2) |
                    i.hasRedundancy),
                Pe.box(Pe.types.sdtp, t)
            );
        }
        static trun(e, t) {
            let i = new Uint8Array(28);
            (t += 36),
                i.set(
                    [
                        0,
                        0,
                        15,
                        1,
                        0,
                        0,
                        0,
                        1,
                        (t >>> 24) & 255,
                        (t >>> 16) & 255,
                        (t >>> 8) & 255,
                        255 & t,
                    ],
                    0
                );
            let o = e.duration,
                r = e.size,
                A = e.flags,
                s = e.cts;
            return (
                i.set(
                    [
                        (o >>> 24) & 255,
                        (o >>> 16) & 255,
                        (o >>> 8) & 255,
                        255 & o,
                        (r >>> 24) & 255,
                        (r >>> 16) & 255,
                        (r >>> 8) & 255,
                        255 & r,
                        (A.isLeading << 2) | A.dependsOn,
                        (A.isDependedOn << 6) |
                            (A.hasRedundancy << 4) |
                            A.isNonSync,
                        0,
                        0,
                        (s >>> 24) & 255,
                        (s >>> 16) & 255,
                        (s >>> 8) & 255,
                        255 & s,
                    ],
                    12
                ),
                Pe.box(Pe.types.trun, i)
            );
        }
        static mdat(e) {
            return Pe.box(Pe.types.mdat, e);
        }
    }
    Pe.init();
    class ze {
        constructor(e) {
            (this.TAG = 'ExpGolomb'),
                (this._buffer = e),
                (this._buffer_index = 0),
                (this._total_bytes = e.byteLength),
                (this._total_bits = 8 * e.byteLength),
                (this._current_word = 0),
                (this._current_word_bits_left = 0);
        }
        destroy() {
            this._buffer = null;
        }
        _fillCurrentWord() {
            let e = this._total_bytes - this._buffer_index,
                t = Math.min(4, e),
                i = new Uint8Array(4);
            i.set(
                this._buffer.subarray(
                    this._buffer_index,
                    this._buffer_index + t
                )
            ),
                (this._current_word = new DataView(i.buffer).getUint32(0, !1)),
                (this._buffer_index += t),
                (this._current_word_bits_left = 8 * t);
        }
        readBits(e) {
            if (e <= this._current_word_bits_left) {
                let t = this._current_word >>> (32 - e);
                return (
                    (this._current_word <<= e),
                    (this._current_word_bits_left -= e),
                    t
                );
            }
            let t = this._current_word_bits_left ? this._current_word : 0;
            t >>>= 32 - this._current_word_bits_left;
            let i = e - this._current_word_bits_left;
            this._fillCurrentWord();
            let o = Math.min(i, this._current_word_bits_left),
                r = this._current_word >>> (32 - o);
            return (
                (this._current_word <<= o),
                (this._current_word_bits_left -= o),
                (t = (t << o) | r),
                t
            );
        }
        readBool() {
            return 1 === this.readBits(1);
        }
        readByte() {
            return this.readBits(8);
        }
        _skipLeadingZero() {
            let e;
            for (e = 0; e < this._current_word_bits_left; e++)
                if (0 != (this._current_word & (2147483648 >>> e)))
                    return (
                        (this._current_word <<= e),
                        (this._current_word_bits_left -= e),
                        e
                    );
            return this._fillCurrentWord(), e + this._skipLeadingZero();
        }
        readUEG() {
            let e = this._skipLeadingZero();
            return this.readBits(e + 1) - 1;
        }
        readSEG() {
            let e = this.readUEG();
            return 1 & e ? (e + 1) >>> 1 : -1 * (e >>> 1);
        }
    }
    class Ye {
        static _ebsp2rbsp(e) {
            let t = e,
                i = t.byteLength,
                o = new Uint8Array(i),
                r = 0;
            for (let e = 0; e < i; e++)
                (e >= 2 && 3 === t[e] && 0 === t[e - 1] && 0 === t[e - 2]) ||
                    ((o[r] = t[e]), r++);
            return new Uint8Array(o.buffer, 0, r);
        }
        static parseSPS(e) {
            let t = Ye._ebsp2rbsp(e),
                i = new ze(t);
            i.readByte();
            let o = i.readByte();
            i.readByte();
            let r = i.readByte();
            i.readUEG();
            let A = Ye.getProfileString(o),
                s = Ye.getLevelString(r),
                n = 1,
                a = 420,
                d = [0, 420, 422, 444],
                c = 8;
            if (
                (100 === o ||
                    110 === o ||
                    122 === o ||
                    244 === o ||
                    44 === o ||
                    83 === o ||
                    86 === o ||
                    118 === o ||
                    128 === o ||
                    138 === o ||
                    144 === o) &&
                ((n = i.readUEG()),
                3 === n && i.readBits(1),
                n <= 3 && (a = d[n]),
                (c = i.readUEG() + 8),
                i.readUEG(),
                i.readBits(1),
                i.readBool())
            ) {
                let e = 3 !== n ? 8 : 12;
                for (let t = 0; t < e; t++)
                    i.readBool() &&
                        (t < 6
                            ? Ye._skipScalingList(i, 16)
                            : Ye._skipScalingList(i, 64));
            }
            i.readUEG();
            let l = i.readUEG();
            if (0 === l) i.readUEG();
            else if (1 === l) {
                i.readBits(1), i.readSEG(), i.readSEG();
                let e = i.readUEG();
                for (let t = 0; t < e; t++) i.readSEG();
            }
            let u = i.readUEG();
            i.readBits(1);
            let h = i.readUEG(),
                p = i.readUEG(),
                m = i.readBits(1);
            0 === m && i.readBits(1), i.readBits(1);
            let g = 0,
                f = 0,
                b = 0,
                y = 0;
            i.readBool() &&
                ((g = i.readUEG()),
                (f = i.readUEG()),
                (b = i.readUEG()),
                (y = i.readUEG()));
            let v = 1,
                w = 1,
                S = 0,
                E = !0,
                B = 0,
                C = 0;
            if (i.readBool()) {
                if (i.readBool()) {
                    let e = i.readByte(),
                        t = [
                            1, 12, 10, 16, 40, 24, 20, 32, 80, 18, 15, 64, 160,
                            4, 3, 2,
                        ],
                        o = [
                            1, 11, 11, 11, 33, 11, 11, 11, 33, 11, 11, 33, 99,
                            3, 2, 1,
                        ];
                    e > 0 && e < 16
                        ? ((v = t[e - 1]), (w = o[e - 1]))
                        : 255 === e &&
                          ((v = (i.readByte() << 8) | i.readByte()),
                          (w = (i.readByte() << 8) | i.readByte()));
                }
                if (
                    (i.readBool() && i.readBool(),
                    i.readBool() &&
                        (i.readBits(4), i.readBool() && i.readBits(24)),
                    i.readBool() && (i.readUEG(), i.readUEG()),
                    i.readBool())
                ) {
                    let e = i.readBits(32),
                        t = i.readBits(32);
                    (E = i.readBool()), (B = t), (C = 2 * e), (S = B / C);
                }
            }
            let R = 1;
            (1 === v && 1 === w) || (R = v / w);
            let k = 0,
                T = 0;
            if (0 === n) (k = 1), (T = 2 - m);
            else {
                (k = 3 === n ? 1 : 2), (T = (1 === n ? 2 : 1) * (2 - m));
            }
            let I = 16 * (h + 1),
                D = 16 * (p + 1) * (2 - m);
            (I -= (g + f) * k), (D -= (b + y) * T);
            let x = Math.ceil(I * R);
            return (
                i.destroy(),
                (i = null),
                {
                    profile_string: A,
                    level_string: s,
                    bit_depth: c,
                    ref_frames: u,
                    chroma_format: a,
                    chroma_format_string: Ye.getChromaFormatString(a),
                    frame_rate: { fixed: E, fps: S, fps_den: C, fps_num: B },
                    sar_ratio: { width: v, height: w },
                    codec_size: { width: I, height: D },
                    present_size: { width: x, height: D },
                }
            );
        }
        static _skipScalingList(e, t) {
            let i = 8,
                o = 8,
                r = 0;
            for (let A = 0; A < t; A++)
                0 !== o && ((r = e.readSEG()), (o = (i + r + 256) % 256)),
                    (i = 0 === o ? i : o);
        }
        static getProfileString(e) {
            switch (e) {
                case 66:
                    return 'Baseline';
                case 77:
                    return 'Main';
                case 88:
                    return 'Extended';
                case 100:
                    return 'High';
                case 110:
                    return 'High10';
                case 122:
                    return 'High422';
                case 244:
                    return 'High444';
                default:
                    return 'Unknown';
            }
        }
        static getLevelString(e) {
            return (e / 10).toFixed(1);
        }
        static getChromaFormatString(e) {
            switch (e) {
                case 420:
                    return '4:2:0';
                case 422:
                    return '4:2:2';
                case 444:
                    return '4:4:4';
                default:
                    return 'Unknown';
            }
        }
    }
    class He extends ve {
        constructor(e) {
            super(),
                (this.player = e),
                (this.isAvc = !0),
                (this.mediaSource = new window.MediaSource()),
                (this.sourceBuffer = null),
                (this.hasInit = !1),
                (this.isInitInfo = !1),
                (this.cacheTrack = {}),
                (this.timeInit = !1),
                (this.sequenceNumber = 0),
                (this.mediaSourceOpen = !1),
                (this.bufferList = []),
                (this.dropping = !1),
                (this.player.video.$videoElement.src =
                    window.URL.createObjectURL(this.mediaSource));
            const {
                debug: t,
                events: { proxy: i },
            } = e;
            i(this.mediaSource, 'sourceopen', () => {
                (this.mediaSourceOpen = !0), this.player.emit(E.mseSourceOpen);
            }),
                i(this.mediaSource, 'sourceclose', () => {
                    this.player.emit(E.mseSourceClose);
                }),
                e.debug.log('MediaSource', 'init');
        }
        destroy() {
            this.stop(),
                (this.bufferList = []),
                (this.mediaSource = null),
                (this.mediaSourceOpen = !1),
                (this.sourceBuffer = null),
                (this.hasInit = !1),
                (this.isInitInfo = !1),
                (this.sequenceNumber = 0),
                (this.cacheTrack = null),
                (this.timeInit = !1),
                this.off(),
                this.player.debug.log('MediaSource', 'destroy');
        }
        get state() {
            return this.mediaSource.readyState;
        }
        get isStateOpen() {
            return this.state === q;
        }
        get isStateClosed() {
            return this.state === K;
        }
        get isStateEnded() {
            return this.state === Z;
        }
        get duration() {
            return this.mediaSource.duration;
        }
        set duration(e) {
            this.mediaSource.duration = e;
        }
        decodeVideo(e, t, i) {
            const o = this.player;
            if (this.hasInit) this._decodeVideo(e, t, i);
            else if (i && 0 === e[1]) {
                const r = 15 & e[0];
                if ((o.video.updateVideoInfo({ encTypeCode: r }), r === j))
                    return void this.emit(C.mediaSourceH265NotSupport);
                o._times.decodeStart || (o._times.decodeStart = ce()),
                    this._decodeConfigurationRecord(e, t, i, r),
                    (this.hasInit = !0);
            }
        }
        _doDecode() {
            const e = this.bufferList.shift();
            e && this._decodeVideo(e.payload, e.ts, e.isIframe);
        }
        _decodeConfigurationRecord(e, t, i, o) {
            let r = e.slice(5),
                A = {};
            o === L
                ? (A = (function (e) {
                      const t = {},
                          i = new DataView(e.buffer);
                      let o = i.getUint8(0),
                          r = i.getUint8(1);
                      if ((i.getUint8(2), i.getUint8(3), 1 !== o || 0 === r))
                          return;
                      const A = 1 + (3 & i.getUint8(4));
                      if (3 !== A && 4 !== A) return;
                      let s = 31 & i.getUint8(5);
                      if (0 === s) return;
                      let n = 6;
                      for (let o = 0; o < s; o++) {
                          let r = i.getUint16(n, !1);
                          if (((n += 2), 0 === r)) continue;
                          let A = new Uint8Array(e.buffer, n, r);
                          n += r;
                          let s = Ye.parseSPS(A);
                          if (0 !== o) continue;
                          (t.codecWidth = s.codec_size.width),
                              (t.codecHeight = s.codec_size.height),
                              (t.presentWidth = s.present_size.width),
                              (t.presentHeight = s.present_size.height),
                              (t.profile = s.profile_string),
                              (t.level = s.level_string),
                              (t.bitDepth = s.bit_depth),
                              (t.chromaFormat = s.chroma_format),
                              (t.sarRatio = s.sar_ratio),
                              (t.frameRate = s.frame_rate),
                              (!1 !== s.frame_rate.fixed &&
                                  0 !== s.frame_rate.fps_num &&
                                  0 !== s.frame_rate.fps_den) ||
                                  (t.frameRate = {});
                          let a = t.frameRate.fps_den,
                              d = t.frameRate.fps_num;
                          t.refSampleDuration = t.timescale * (a / d);
                          let c = A.subarray(1, 4),
                              l = 'avc1.';
                          for (let e = 0; e < 3; e++) {
                              let t = c[e].toString(16);
                              t.length < 2 && (t = '0' + t), (l += t);
                          }
                          t.codec = l;
                      }
                      let a = i.getUint8(n);
                      if (0 !== a) {
                          n++;
                          for (let t = 0; t < a; t++) {
                              let t = i.getUint16(n, !1);
                              (n += 2),
                                  0 !== t &&
                                      (new Uint8Array(e.buffer, n, t),
                                      (n += t));
                          }
                          return (t.videoType = 'avc'), t;
                      }
                  })(r))
                : o === j &&
                  (A = (function (e) {
                      const t = { videoType: 'hevc' };
                      let i = 23;
                      if (e[i] !== F) return t;
                      (i += 2), (i += 1);
                      const o = e[i + 1] | (e[i] << 8);
                      i += 2;
                      const r = e.slice(i, i + o);
                      if (
                          (console.log(Uint8Array.from(r)),
                          (i += o),
                          e[i] !== V)
                      )
                          return t;
                      (i += 2), (i += 1);
                      const A = e[i + 1] | (e[i] << 8);
                      i += 2;
                      const s = e.slice(i, i + A);
                      if (
                          (console.log(Uint8Array.from(s)),
                          (i += A),
                          e[i] !== O)
                      )
                          return t;
                      (i += 2), (i += 1);
                      const n = e[i + 1] | (e[i] << 8);
                      i += 2;
                      const a = e.slice(i, i + n);
                      console.log(Uint8Array.from(a));
                      let d = Uint8Array.from(s),
                          c = class {
                              static parseSPS(e) {}
                          }.parseSPS(d);
                      return (
                          (t.codecWidth = c.codec_size.width),
                          (t.codecHeight = c.codec_size.height),
                          (t.presentWidth = c.present_size.width),
                          (t.presentHeight = c.present_size.height),
                          (t.profile = c.profile_string),
                          (t.level = c.level_string),
                          (t.bitDepth = c.bit_depth),
                          (t.chromaFormat = c.chroma_format),
                          (t.sarRatio = c.sar_ratio),
                          t
                      );
                  })(r));
            const s = {
                    id: 1,
                    type: 'video',
                    timescale: 1e3,
                    duration: 0,
                    avcc: r,
                    codecWidth: A.codecWidth,
                    codecHeight: A.codecHeight,
                    videoType: A.videoType,
                },
                n = Pe.generateInitSegment(s);
            (this.isAvc = !0),
                this.appendBuffer(n.buffer),
                (this.sequenceNumber = 0),
                (this.cacheTrack = null),
                (this.timeInit = !1);
        }
        _decodeVideo(e, t, i) {
            const o = this.player;
            let r = e.slice(5),
                A = r.byteLength,
                s = t;
            const n = o.video.$videoElement;
            if (
                (n.buffered.length > 1 &&
                    (this.removeBuffer(n.buffered.start(0), n.buffered.end(0)),
                    (this.timeInit = !1)),
                n.drop && s - this.cacheTrack.dts > 1e3)
            )
                (n.drop = !1), (this.cacheTrack = {});
            else if (this.cacheTrack && s > this.cacheTrack.dts) {
                let e = 8 + this.cacheTrack.size,
                    i = new Uint8Array(e);
                (i[0] = (e >>> 24) & 255),
                    (i[1] = (e >>> 16) & 255),
                    (i[2] = (e >>> 8) & 255),
                    (i[3] = 255 & e),
                    i.set(Pe.types.mdat, 4),
                    i.set(this.cacheTrack.data, 8),
                    (this.cacheTrack.duration = s - this.cacheTrack.dts);
                let r = Pe.moof(this.cacheTrack, this.cacheTrack.dts),
                    A = new Uint8Array(r.byteLength + i.byteLength);
                A.set(r, 0),
                    A.set(i, r.byteLength),
                    this.appendBuffer(A.buffer),
                    o.handleRender(),
                    o.updateStats({ fps: !0, ts: t, buf: o.demux.delay }),
                    o._times.videoStart ||
                        ((o._times.videoStart = ce()),
                        o.handlePlayToRenderTimes());
            } else
                o.debug.log(
                    'MediaSource',
                    'timeInit set false , cacheTrack = {}'
                ),
                    (this.timeInit = !1),
                    (this.cacheTrack = {});
            (this.cacheTrack.id = 1),
                (this.cacheTrack.sequenceNumber = ++this.sequenceNumber),
                (this.cacheTrack.size = A),
                (this.cacheTrack.dts = s),
                (this.cacheTrack.cts = 0),
                (this.cacheTrack.isKeyframe = i),
                (this.cacheTrack.data = r),
                (this.cacheTrack.flags = {
                    isLeading: 0,
                    dependsOn: i ? 2 : 1,
                    isDependedOn: i ? 1 : 0,
                    hasRedundancy: 0,
                    isNonSync: i ? 0 : 1,
                }),
                this.timeInit ||
                    1 !== n.buffered.length ||
                    (o.debug.log('MediaSource', 'timeInit set true'),
                    (this.timeInit = !0),
                    (n.currentTime = n.buffered.end(0))),
                !this.isInitInfo &&
                    n.videoWidth > 0 &&
                    n.videoHeight > 0 &&
                    (o.debug.log(
                        'MediaSource',
                        `updateVideoInfo: ${n.videoWidth},${n.videoHeight}`
                    ),
                    o.video.updateVideoInfo({
                        width: n.videoWidth,
                        height: n.videoHeight,
                    }),
                    o.video.initCanvasViewSize(),
                    (this.isInitInfo = !0));
        }
        appendBuffer(e) {
            const {
                debug: t,
                events: { proxy: i },
            } = this.player;
            null === this.sourceBuffer &&
                ((this.sourceBuffer = this.mediaSource.addSourceBuffer(X)),
                i(this.sourceBuffer, 'error', (e) => {
                    this.player.emit(E.mseSourceBufferError, e),
                        this.dropSourceBuffer(!0);
                })),
                !1 === this.sourceBuffer.updating && this.isStateOpen
                    ? this.sourceBuffer.appendBuffer(e)
                    : this.isStateClosed
                    ? this.player.emit(
                          E.mseSourceBufferError,
                          'mediaSource is not attached to video or mediaSource is closed'
                      )
                    : this.isStateEnded
                    ? this.player.emit(
                          E.mseSourceBufferError,
                          'mediaSource is closed'
                      )
                    : !0 === this.sourceBuffer.updating &&
                      (this.player.emit(E.mseSourceBufferBusy),
                      this.dropSourceBuffer(!0));
        }
        stop() {
            this.isStateOpen && this.sourceBuffer && this.sourceBuffer.abort(),
                this.endOfStream();
        }
        dropSourceBuffer(e) {
            const t = this.player.video.$videoElement;
            (this.dropping = e),
                t.buffered.length > 0 &&
                    t.buffered.end(0) - t.currentTime > 1 &&
                    (t.currentTime = t.buffered.end(0));
        }
        removeBuffer(e, t) {
            if (this.isStateOpen && !1 === this.sourceBuffer.updating)
                try {
                    this.sourceBuffer.remove(e, t);
                } catch (e) {
                    console.error(e);
                }
        }
        endOfStream() {
            this.isStateOpen && this.mediaSource.endOfStream();
        }
    }
    const Xe = () =>
            'undefined' != typeof navigator &&
            parseFloat(
                (
                    '' +
                    (/CPU.*OS ([0-9_]{3,4})[0-9_]{0,1}|(CPU like).*AppleWebKit.*Mobile/i.exec(
                        navigator.userAgent
                    ) || [0, ''])[1]
                )
                    .replace('undefined', '3_2')
                    .replace('_', '.')
                    .replace('_', '')
            ) < 10 &&
            !window.MSStream,
        Ze = () => 'wakeLock' in navigator;
    class qe {
        constructor(e) {
            if (((this.player = e), (this.enabled = !1), Ze())) {
                this._wakeLock = null;
                const e = () => {
                    null !== this._wakeLock &&
                        'visible' === document.visibilityState &&
                        this.enable();
                };
                document.addEventListener('visibilitychange', e),
                    document.addEventListener('fullscreenchange', e);
            } else
                Xe()
                    ? (this.noSleepTimer = null)
                    : ((this.noSleepVideo = document.createElement('video')),
                      this.noSleepVideo.setAttribute('title', 'No Sleep'),
                      this.noSleepVideo.setAttribute('playsinline', ''),
                      this._addSourceToVideo(
                          this.noSleepVideo,
                          'webm',
                          'data:video/webm;base64,GkXfowEAAAAAAAAfQoaBAUL3gQFC8oEEQvOBCEKChHdlYm1Ch4EEQoWBAhhTgGcBAAAAAAAVkhFNm3RALE27i1OrhBVJqWZTrIHfTbuMU6uEFlSua1OsggEwTbuMU6uEHFO7a1OsghV17AEAAAAAAACkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmAQAAAAAAAEUq17GDD0JATYCNTGF2ZjU1LjMzLjEwMFdBjUxhdmY1NS4zMy4xMDBzpJBlrrXf3DCDVB8KcgbMpcr+RImIQJBgAAAAAAAWVK5rAQAAAAAAD++uAQAAAAAAADLXgQFzxYEBnIEAIrWcg3VuZIaFVl9WUDiDgQEj44OEAmJaAOABAAAAAAAABrCBsLqBkK4BAAAAAAAPq9eBAnPFgQKcgQAitZyDdW5khohBX1ZPUkJJU4OBAuEBAAAAAAAAEZ+BArWIQOdwAAAAAABiZIEgY6JPbwIeVgF2b3JiaXMAAAAAAoC7AAAAAAAAgLUBAAAAAAC4AQN2b3JiaXMtAAAAWGlwaC5PcmcgbGliVm9yYmlzIEkgMjAxMDExMDEgKFNjaGF1ZmVudWdnZXQpAQAAABUAAABlbmNvZGVyPUxhdmM1NS41Mi4xMDIBBXZvcmJpcyVCQ1YBAEAAACRzGCpGpXMWhBAaQlAZ4xxCzmvsGUJMEYIcMkxbyyVzkCGkoEKIWyiB0JBVAABAAACHQXgUhIpBCCGEJT1YkoMnPQghhIg5eBSEaUEIIYQQQgghhBBCCCGERTlokoMnQQgdhOMwOAyD5Tj4HIRFOVgQgydB6CCED0K4moOsOQghhCQ1SFCDBjnoHITCLCiKgsQwuBaEBDUojILkMMjUgwtCiJqDSTX4GoRnQXgWhGlBCCGEJEFIkIMGQcgYhEZBWJKDBjm4FITLQagahCo5CB+EIDRkFQCQAACgoiiKoigKEBqyCgDIAAAQQFEUx3EcyZEcybEcCwgNWQUAAAEACAAAoEiKpEiO5EiSJFmSJVmSJVmS5omqLMuyLMuyLMsyEBqyCgBIAABQUQxFcRQHCA1ZBQBkAAAIoDiKpViKpWiK54iOCISGrAIAgAAABAAAEDRDUzxHlETPVFXXtm3btm3btm3btm3btm1blmUZCA1ZBQBAAAAQ0mlmqQaIMAMZBkJDVgEACAAAgBGKMMSA0JBVAABAAACAGEoOogmtOd+c46BZDppKsTkdnEi1eZKbirk555xzzsnmnDHOOeecopxZDJoJrTnnnMSgWQqaCa0555wnsXnQmiqtOeeccc7pYJwRxjnnnCateZCajbU555wFrWmOmkuxOeecSLl5UptLtTnnnHPOOeecc84555zqxekcnBPOOeecqL25lpvQxTnnnE/G6d6cEM4555xzzjnnnHPOOeecIDRkFQAABABAEIaNYdwpCNLnaCBGEWIaMulB9+gwCRqDnELq0ehopJQ6CCWVcVJKJwgNWQUAAAIAQAghhRRSSCGFFFJIIYUUYoghhhhyyimnoIJKKqmooowyyyyzzDLLLLPMOuyssw47DDHEEEMrrcRSU2011lhr7jnnmoO0VlprrbVSSimllFIKQkNWAQAgAAAEQgYZZJBRSCGFFGKIKaeccgoqqIDQkFUAACAAgAAAAABP8hzRER3RER3RER3RER3R8RzPESVREiVREi3TMjXTU0VVdWXXlnVZt31b2IVd933d933d+HVhWJZlWZZlWZZlWZZlWZZlWZYgNGQVAAACAAAghBBCSCGFFFJIKcYYc8w56CSUEAgNWQUAAAIACAAAAHAUR3EcyZEcSbIkS9IkzdIsT/M0TxM9URRF0zRV0RVdUTdtUTZl0zVdUzZdVVZtV5ZtW7Z125dl2/d93/d93/d93/d93/d9XQdCQ1YBABIAADqSIymSIimS4ziOJElAaMgqAEAGAEAAAIriKI7jOJIkSZIlaZJneZaomZrpmZ4qqkBoyCoAABAAQAAAAAAAAIqmeIqpeIqoeI7oiJJomZaoqZoryqbsuq7ruq7ruq7ruq7ruq7ruq7ruq7ruq7ruq7ruq7ruq7ruq4LhIasAgAkAAB0JEdyJEdSJEVSJEdygNCQVQCADACAAAAcwzEkRXIsy9I0T/M0TxM90RM901NFV3SB0JBVAAAgAIAAAAAAAAAMybAUy9EcTRIl1VItVVMt1VJF1VNVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVN0zRNEwgNWQkAkAEAkBBTLS3GmgmLJGLSaqugYwxS7KWxSCpntbfKMYUYtV4ah5RREHupJGOKQcwtpNApJq3WVEKFFKSYYyoVUg5SIDRkhQAQmgHgcBxAsixAsiwAAAAAAAAAkDQN0DwPsDQPAAAAAAAAACRNAyxPAzTPAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABA0jRA8zxA8zwAAAAAAAAA0DwP8DwR8EQRAAAAAAAAACzPAzTRAzxRBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABA0jRA8zxA8zwAAAAAAAAAsDwP8EQR0DwRAAAAAAAAACzPAzxRBDzRAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAEOAAABBgIRQasiIAiBMAcEgSJAmSBM0DSJYFTYOmwTQBkmVB06BpME0AAAAAAAAAAAAAJE2DpkHTIIoASdOgadA0iCIAAAAAAAAAAAAAkqZB06BpEEWApGnQNGgaRBEAAAAAAAAAAAAAzzQhihBFmCbAM02IIkQRpgkAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAGHAAAAgwoQwUGrIiAIgTAHA4imUBAIDjOJYFAACO41gWAABYliWKAABgWZooAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAYcAAACDChDBQashIAiAIAcCiKZQHHsSzgOJYFJMmyAJYF0DyApgFEEQAIAAAocAAACLBBU2JxgEJDVgIAUQAABsWxLE0TRZKkaZoniiRJ0zxPFGma53meacLzPM80IYqiaJoQRVE0TZimaaoqME1VFQAAUOAAABBgg6bE4gCFhqwEAEICAByKYlma5nmeJ4qmqZokSdM8TxRF0TRNU1VJkqZ5niiKommapqqyLE3zPFEURdNUVVWFpnmeKIqiaaqq6sLzPE8URdE0VdV14XmeJ4qiaJqq6roQRVE0TdNUTVV1XSCKpmmaqqqqrgtETxRNU1Vd13WB54miaaqqq7ouEE3TVFVVdV1ZBpimaaqq68oyQFVV1XVdV5YBqqqqruu6sgxQVdd1XVmWZQCu67qyLMsCAAAOHAAAAoygk4wqi7DRhAsPQKEhKwKAKAAAwBimFFPKMCYhpBAaxiSEFEImJaXSUqogpFJSKRWEVEoqJaOUUmopVRBSKamUCkIqJZVSAADYgQMA2IGFUGjISgAgDwCAMEYpxhhzTiKkFGPOOScRUoox55yTSjHmnHPOSSkZc8w556SUzjnnnHNSSuacc845KaVzzjnnnJRSSuecc05KKSWEzkEnpZTSOeecEwAAVOAAABBgo8jmBCNBhYasBABSAQAMjmNZmuZ5omialiRpmud5niiapiZJmuZ5nieKqsnzPE8URdE0VZXneZ4oiqJpqirXFUXTNE1VVV2yLIqmaZqq6rowTdNUVdd1XZimaaqq67oubFtVVdV1ZRm2raqq6rqyDFzXdWXZloEsu67s2rIAAPAEBwCgAhtWRzgpGgssNGQlAJABAEAYg5BCCCFlEEIKIYSUUggJAAAYcAAACDChDBQashIASAUAAIyx1lprrbXWQGettdZaa62AzFprrbXWWmuttdZaa6211lJrrbXWWmuttdZaa6211lprrbXWWmuttdZaa6211lprrbXWWmuttdZaa6211lprrbXWWmstpZRSSimllFJKKaWUUkoppZRSSgUA+lU4APg/2LA6wknRWGChISsBgHAAAMAYpRhzDEIppVQIMeacdFRai7FCiDHnJKTUWmzFc85BKCGV1mIsnnMOQikpxVZjUSmEUlJKLbZYi0qho5JSSq3VWIwxqaTWWoutxmKMSSm01FqLMRYjbE2ptdhqq7EYY2sqLbQYY4zFCF9kbC2m2moNxggjWywt1VprMMYY3VuLpbaaizE++NpSLDHWXAAAd4MDAESCjTOsJJ0VjgYXGrISAAgJACAQUooxxhhzzjnnpFKMOeaccw5CCKFUijHGnHMOQgghlIwx5pxzEEIIIYRSSsaccxBCCCGEkFLqnHMQQgghhBBKKZ1zDkIIIYQQQimlgxBCCCGEEEoopaQUQgghhBBCCKmklEIIIYRSQighlZRSCCGEEEIpJaSUUgohhFJCCKGElFJKKYUQQgillJJSSimlEkoJJYQSUikppRRKCCGUUkpKKaVUSgmhhBJKKSWllFJKIYQQSikFAAAcOAAABBhBJxlVFmGjCRcegEJDVgIAZAAAkKKUUiktRYIipRikGEtGFXNQWoqocgxSzalSziDmJJaIMYSUk1Qy5hRCDELqHHVMKQYtlRhCxhik2HJLoXMOAAAAQQCAgJAAAAMEBTMAwOAA4XMQdAIERxsAgCBEZohEw0JweFAJEBFTAUBigkIuAFRYXKRdXECXAS7o4q4DIQQhCEEsDqCABByccMMTb3jCDU7QKSp1IAAAAAAADADwAACQXAAREdHMYWRobHB0eHyAhIiMkAgAAAAAABcAfAAAJCVAREQ0cxgZGhscHR4fICEiIyQBAIAAAgAAAAAggAAEBAQAAAAAAAIAAAAEBB9DtnUBAAAAAAAEPueBAKOFggAAgACjzoEAA4BwBwCdASqwAJAAAEcIhYWIhYSIAgIABhwJ7kPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99YAD+/6tQgKOFggADgAqjhYIAD4AOo4WCACSADqOZgQArADECAAEQEAAYABhYL/QACIBDmAYAAKOFggA6gA6jhYIAT4AOo5mBAFMAMQIAARAQABgAGFgv9AAIgEOYBgAAo4WCAGSADqOFggB6gA6jmYEAewAxAgABEBAAGAAYWC/0AAiAQ5gGAACjhYIAj4AOo5mBAKMAMQIAARAQABgAGFgv9AAIgEOYBgAAo4WCAKSADqOFggC6gA6jmYEAywAxAgABEBAAGAAYWC/0AAiAQ5gGAACjhYIAz4AOo4WCAOSADqOZgQDzADECAAEQEAAYABhYL/QACIBDmAYAAKOFggD6gA6jhYIBD4AOo5iBARsAEQIAARAQFGAAYWC/0AAiAQ5gGACjhYIBJIAOo4WCATqADqOZgQFDADECAAEQEAAYABhYL/QACIBDmAYAAKOFggFPgA6jhYIBZIAOo5mBAWsAMQIAARAQABgAGFgv9AAIgEOYBgAAo4WCAXqADqOFggGPgA6jmYEBkwAxAgABEBAAGAAYWC/0AAiAQ5gGAACjhYIBpIAOo4WCAbqADqOZgQG7ADECAAEQEAAYABhYL/QACIBDmAYAAKOFggHPgA6jmYEB4wAxAgABEBAAGAAYWC/0AAiAQ5gGAACjhYIB5IAOo4WCAfqADqOZgQILADECAAEQEAAYABhYL/QACIBDmAYAAKOFggIPgA6jhYICJIAOo5mBAjMAMQIAARAQABgAGFgv9AAIgEOYBgAAo4WCAjqADqOFggJPgA6jmYECWwAxAgABEBAAGAAYWC/0AAiAQ5gGAACjhYICZIAOo4WCAnqADqOZgQKDADECAAEQEAAYABhYL/QACIBDmAYAAKOFggKPgA6jhYICpIAOo5mBAqsAMQIAARAQABgAGFgv9AAIgEOYBgAAo4WCArqADqOFggLPgA6jmIEC0wARAgABEBAUYABhYL/QACIBDmAYAKOFggLkgA6jhYIC+oAOo5mBAvsAMQIAARAQABgAGFgv9AAIgEOYBgAAo4WCAw+ADqOZgQMjADECAAEQEAAYABhYL/QACIBDmAYAAKOFggMkgA6jhYIDOoAOo5mBA0sAMQIAARAQABgAGFgv9AAIgEOYBgAAo4WCA0+ADqOFggNkgA6jmYEDcwAxAgABEBAAGAAYWC/0AAiAQ5gGAACjhYIDeoAOo4WCA4+ADqOZgQObADECAAEQEAAYABhYL/QACIBDmAYAAKOFggOkgA6jhYIDuoAOo5mBA8MAMQIAARAQABgAGFgv9AAIgEOYBgAAo4WCA8+ADqOFggPkgA6jhYID+oAOo4WCBA+ADhxTu2sBAAAAAAAAEbuPs4EDt4r3gQHxghEr8IEK'
                      ),
                      this._addSourceToVideo(
                          this.noSleepVideo,
                          'mp4',
                          'data:video/mp4;base64,AAAAHGZ0eXBNNFYgAAACAGlzb21pc28yYXZjMQAAAAhmcmVlAAAGF21kYXTeBAAAbGliZmFhYyAxLjI4AABCAJMgBDIARwAAArEGBf//rdxF6b3m2Ui3lizYINkj7u94MjY0IC0gY29yZSAxNDIgcjIgOTU2YzhkOCAtIEguMjY0L01QRUctNCBBVkMgY29kZWMgLSBDb3B5bGVmdCAyMDAzLTIwMTQgLSBodHRwOi8vd3d3LnZpZGVvbGFuLm9yZy94MjY0Lmh0bWwgLSBvcHRpb25zOiBjYWJhYz0wIHJlZj0zIGRlYmxvY2s9MTowOjAgYW5hbHlzZT0weDE6MHgxMTEgbWU9aGV4IHN1Ym1lPTcgcHN5PTEgcHN5X3JkPTEuMDA6MC4wMCBtaXhlZF9yZWY9MSBtZV9yYW5nZT0xNiBjaHJvbWFfbWU9MSB0cmVsbGlzPTEgOHg4ZGN0PTAgY3FtPTAgZGVhZHpvbmU9MjEsMTEgZmFzdF9wc2tpcD0xIGNocm9tYV9xcF9vZmZzZXQ9LTIgdGhyZWFkcz02IGxvb2thaGVhZF90aHJlYWRzPTEgc2xpY2VkX3RocmVhZHM9MCBucj0wIGRlY2ltYXRlPTEgaW50ZXJsYWNlZD0wIGJsdXJheV9jb21wYXQ9MCBjb25zdHJhaW5lZF9pbnRyYT0wIGJmcmFtZXM9MCB3ZWlnaHRwPTAga2V5aW50PTI1MCBrZXlpbnRfbWluPTI1IHNjZW5lY3V0PTQwIGludHJhX3JlZnJlc2g9MCByY19sb29rYWhlYWQ9NDAgcmM9Y3JmIG1idHJlZT0xIGNyZj0yMy4wIHFjb21wPTAuNjAgcXBtaW49MCBxcG1heD02OSBxcHN0ZXA9NCB2YnZfbWF4cmF0ZT03NjggdmJ2X2J1ZnNpemU9MzAwMCBjcmZfbWF4PTAuMCBuYWxfaHJkPW5vbmUgZmlsbGVyPTAgaXBfcmF0aW89MS40MCBhcT0xOjEuMDAAgAAAAFZliIQL8mKAAKvMnJycnJycnJycnXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXiEASZACGQAjgCEASZACGQAjgAAAAAdBmjgX4GSAIQBJkAIZACOAAAAAB0GaVAX4GSAhAEmQAhkAI4AhAEmQAhkAI4AAAAAGQZpgL8DJIQBJkAIZACOAIQBJkAIZACOAAAAABkGagC/AySEASZACGQAjgAAAAAZBmqAvwMkhAEmQAhkAI4AhAEmQAhkAI4AAAAAGQZrAL8DJIQBJkAIZACOAAAAABkGa4C/AySEASZACGQAjgCEASZACGQAjgAAAAAZBmwAvwMkhAEmQAhkAI4AAAAAGQZsgL8DJIQBJkAIZACOAIQBJkAIZACOAAAAABkGbQC/AySEASZACGQAjgCEASZACGQAjgAAAAAZBm2AvwMkhAEmQAhkAI4AAAAAGQZuAL8DJIQBJkAIZACOAIQBJkAIZACOAAAAABkGboC/AySEASZACGQAjgAAAAAZBm8AvwMkhAEmQAhkAI4AhAEmQAhkAI4AAAAAGQZvgL8DJIQBJkAIZACOAAAAABkGaAC/AySEASZACGQAjgCEASZACGQAjgAAAAAZBmiAvwMkhAEmQAhkAI4AhAEmQAhkAI4AAAAAGQZpAL8DJIQBJkAIZACOAAAAABkGaYC/AySEASZACGQAjgCEASZACGQAjgAAAAAZBmoAvwMkhAEmQAhkAI4AAAAAGQZqgL8DJIQBJkAIZACOAIQBJkAIZACOAAAAABkGawC/AySEASZACGQAjgAAAAAZBmuAvwMkhAEmQAhkAI4AhAEmQAhkAI4AAAAAGQZsAL8DJIQBJkAIZACOAAAAABkGbIC/AySEASZACGQAjgCEASZACGQAjgAAAAAZBm0AvwMkhAEmQAhkAI4AhAEmQAhkAI4AAAAAGQZtgL8DJIQBJkAIZACOAAAAABkGbgCvAySEASZACGQAjgCEASZACGQAjgAAAAAZBm6AnwMkhAEmQAhkAI4AhAEmQAhkAI4AhAEmQAhkAI4AhAEmQAhkAI4AAAAhubW9vdgAAAGxtdmhkAAAAAAAAAAAAAAAAAAAD6AAABDcAAQAAAQAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAzB0cmFrAAAAXHRraGQAAAADAAAAAAAAAAAAAAABAAAAAAAAA+kAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAALAAAACQAAAAAAAkZWR0cwAAABxlbHN0AAAAAAAAAAEAAAPpAAAAAAABAAAAAAKobWRpYQAAACBtZGhkAAAAAAAAAAAAAAAAAAB1MAAAdU5VxAAAAAAALWhkbHIAAAAAAAAAAHZpZGUAAAAAAAAAAAAAAABWaWRlb0hhbmRsZXIAAAACU21pbmYAAAAUdm1oZAAAAAEAAAAAAAAAAAAAACRkaW5mAAAAHGRyZWYAAAAAAAAAAQAAAAx1cmwgAAAAAQAAAhNzdGJsAAAAr3N0c2QAAAAAAAAAAQAAAJ9hdmMxAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAALAAkABIAAAASAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGP//AAAALWF2Y0MBQsAN/+EAFWdCwA3ZAsTsBEAAAPpAADqYA8UKkgEABWjLg8sgAAAAHHV1aWRraEDyXyRPxbo5pRvPAyPzAAAAAAAAABhzdHRzAAAAAAAAAAEAAAAeAAAD6QAAABRzdHNzAAAAAAAAAAEAAAABAAAAHHN0c2MAAAAAAAAAAQAAAAEAAAABAAAAAQAAAIxzdHN6AAAAAAAAAAAAAAAeAAADDwAAAAsAAAALAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAACgAAAAoAAAAKAAAAiHN0Y28AAAAAAAAAHgAAAEYAAANnAAADewAAA5gAAAO0AAADxwAAA+MAAAP2AAAEEgAABCUAAARBAAAEXQAABHAAAASMAAAEnwAABLsAAATOAAAE6gAABQYAAAUZAAAFNQAABUgAAAVkAAAFdwAABZMAAAWmAAAFwgAABd4AAAXxAAAGDQAABGh0cmFrAAAAXHRraGQAAAADAAAAAAAAAAAAAAACAAAAAAAABDcAAAAAAAAAAAAAAAEBAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAkZWR0cwAAABxlbHN0AAAAAAAAAAEAAAQkAAADcAABAAAAAAPgbWRpYQAAACBtZGhkAAAAAAAAAAAAAAAAAAC7gAAAykBVxAAAAAAALWhkbHIAAAAAAAAAAHNvdW4AAAAAAAAAAAAAAABTb3VuZEhhbmRsZXIAAAADi21pbmYAAAAQc21oZAAAAAAAAAAAAAAAJGRpbmYAAAAcZHJlZgAAAAAAAAABAAAADHVybCAAAAABAAADT3N0YmwAAABnc3RzZAAAAAAAAAABAAAAV21wNGEAAAAAAAAAAQAAAAAAAAAAAAIAEAAAAAC7gAAAAAAAM2VzZHMAAAAAA4CAgCIAAgAEgICAFEAVBbjYAAu4AAAADcoFgICAAhGQBoCAgAECAAAAIHN0dHMAAAAAAAAAAgAAADIAAAQAAAAAAQAAAkAAAAFUc3RzYwAAAAAAAAAbAAAAAQAAAAEAAAABAAAAAgAAAAIAAAABAAAAAwAAAAEAAAABAAAABAAAAAIAAAABAAAABgAAAAEAAAABAAAABwAAAAIAAAABAAAACAAAAAEAAAABAAAACQAAAAIAAAABAAAACgAAAAEAAAABAAAACwAAAAIAAAABAAAADQAAAAEAAAABAAAADgAAAAIAAAABAAAADwAAAAEAAAABAAAAEAAAAAIAAAABAAAAEQAAAAEAAAABAAAAEgAAAAIAAAABAAAAFAAAAAEAAAABAAAAFQAAAAIAAAABAAAAFgAAAAEAAAABAAAAFwAAAAIAAAABAAAAGAAAAAEAAAABAAAAGQAAAAIAAAABAAAAGgAAAAEAAAABAAAAGwAAAAIAAAABAAAAHQAAAAEAAAABAAAAHgAAAAIAAAABAAAAHwAAAAQAAAABAAAA4HN0c3oAAAAAAAAAAAAAADMAAAAaAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAAAJAAAACQAAAAkAAACMc3RjbwAAAAAAAAAfAAAALAAAA1UAAANyAAADhgAAA6IAAAO+AAAD0QAAA+0AAAQAAAAEHAAABC8AAARLAAAEZwAABHoAAASWAAAEqQAABMUAAATYAAAE9AAABRAAAAUjAAAFPwAABVIAAAVuAAAFgQAABZ0AAAWwAAAFzAAABegAAAX7AAAGFwAAAGJ1ZHRhAAAAWm1ldGEAAAAAAAAAIWhkbHIAAAAAAAAAAG1kaXJhcHBsAAAAAAAAAAAAAAAALWlsc3QAAAAlqXRvbwAAAB1kYXRhAAAAAQAAAABMYXZmNTUuMzMuMTAw'
                      ),
                      this.noSleepVideo.addEventListener(
                          'loadedmetadata',
                          () => {
                              this.noSleepVideo.duration <= 1
                                  ? this.noSleepVideo.setAttribute('loop', '')
                                  : this.noSleepVideo.addEventListener(
                                        'timeupdate',
                                        () => {
                                            this.noSleepVideo.currentTime >
                                                0.5 &&
                                                (this.noSleepVideo.currentTime =
                                                    Math.random());
                                        }
                                    );
                          }
                      ));
        }
        _addSourceToVideo(e, t, i) {
            var o = document.createElement('source');
            (o.src = i), (o.type = `video/${t}`), e.appendChild(o);
        }
        get isEnabled() {
            return this.enabled;
        }
        enable() {
            const e = this.player.debug;
            if (Ze())
                return navigator.wakeLock
                    .request('screen')
                    .then((t) => {
                        (this._wakeLock = t),
                            (this.enabled = !0),
                            e.log('wakeLock', 'Wake Lock active.'),
                            this._wakeLock.addEventListener('release', () => {
                                e.log('wakeLock', 'Wake Lock released.');
                            });
                    })
                    .catch((t) => {
                        throw (
                            ((this.enabled = !1),
                            e.error('wakeLock', `${t.name}, ${t.message}`),
                            t)
                        );
                    });
            if (Xe())
                return (
                    this.disable(),
                    (this.noSleepTimer = window.setInterval(() => {
                        document.hidden ||
                            ((window.location.href =
                                window.location.href.split('#')[0]),
                            window.setTimeout(window.stop, 0));
                    }, 15e3)),
                    (this.enabled = !0),
                    Promise.resolve()
                );
            return this.noSleepVideo
                .play()
                .then((e) => ((this.enabled = !0), e))
                .catch((e) => {
                    throw ((this.enabled = !1), e);
                });
        }
        disable() {
            const e = this.player.debug;
            Ze()
                ? (this._wakeLock && this._wakeLock.release(),
                  (this._wakeLock = null))
                : Xe()
                ? this.noSleepTimer &&
                  (e.warn(
                      'wakeLock',
                      'NoSleep now disabled for older iOS devices.'
                  ),
                  window.clearInterval(this.noSleepTimer),
                  (this.noSleepTimer = null))
                : this.noSleepVideo.pause(),
                (this.enabled = !1);
        }
    }
    class Ke extends ve {
        constructor(e, t) {
            var i;
            super(),
                (this.$container = e),
                (this._opt = Object.assign({}, r, t)),
                (this.debug = new ie(this)),
                this._opt.useWCS &&
                    (this._opt.useWCS = 'VideoEncoder' in window),
                this._opt.useMSE &&
                    (this._opt.useMSE =
                        window.MediaSource &&
                        window.MediaSource.isTypeSupported(X)),
                this._opt.useMSE
                    ? (this._opt.useWCS &&
                          this.debug.log('Player', 'useWCS set true->false'),
                      this._opt.forceNoOffscreen ||
                          this.debug.log(
                              'Player',
                              'forceNoOffscreen set false->true'
                          ),
                      (this._opt.useWCS = !1),
                      (this._opt.forceNoOffscreen = !0))
                    : this._opt.useWCS,
                this._opt.forceNoOffscreen ||
                    ('undefined' == typeof OffscreenCanvas
                        ? ((this._opt.forceNoOffscreen = !0),
                          (this._opt.useOffscreen = !1))
                        : (this._opt.useOffscreen = !0)),
                this._opt.hasAudio || (this._opt.operateBtns.audio = !1),
                (this._opt.hasControl = this._hasControl()),
                (this._loading = !1),
                (this._playing = !1),
                (this._hasLoaded = !1),
                (this._checkHeartTimeout = null),
                (this._checkLoadingTimeout = null),
                (this._startBpsTime = null),
                (this._isPlayingBeforePageHidden = !1),
                (this._stats = { buf: 0, fps: 0, abps: 0, vbps: 0, ts: 0 }),
                (this._times = {
                    playInitStart: '',
                    playStart: '',
                    streamStart: '',
                    streamResponse: '',
                    demuxStart: '',
                    decodeStart: '',
                    videoStart: '',
                    playTimestamp: '',
                    streamTimestamp: '',
                    streamResponseTimestamp: '',
                    demuxTimestamp: '',
                    decodeTimestamp: '',
                    videoTimestamp: '',
                    allTimestamp: '',
                }),
                (this._videoTimestamp = 0),
                (this._audioTimestamp = 0),
                (i = this),
                Object.defineProperty(i, 'rect', {
                    get: () => {
                        const e = i.$container.getBoundingClientRect();
                        return (
                            (e.width = Math.max(
                                e.width,
                                i.$container.clientWidth
                            )),
                            (e.height = Math.max(
                                e.height,
                                i.$container.clientHeight
                            )),
                            e
                        );
                    },
                }),
                ['bottom', 'height', 'left', 'right', 'top', 'width'].forEach(
                    (e) => {
                        Object.defineProperty(i, e, { get: () => i.rect[e] });
                    }
                ),
                (this.events = new oe(this)),
                (this.video = new Be(this)),
                this._opt.hasAudio && (this.audio = new Re(this)),
                (this.recorder = new Le(this)),
                this._onlyMseOrWcsVideo()
                    ? (this.loaded = !0)
                    : (this.decoderWorker = new je(this)),
                (this.stream = null),
                (this.demux = null),
                this._opt.useWCS && (this.webcodecsDecoder = new Me(this)),
                this._opt.useMSE && (this.mseDecoder = new He(this)),
                (this.control = new Ne(this)),
                (this.keepScreenOn = new qe(this)),
                ((e) => {
                    try {
                        const t = () => {
                            e.emit(B.fullscreen, e.fullscreen),
                                e.fullscreen
                                    ? e._opt.useMSE && e.resize()
                                    : e.resize();
                        };
                        se.on('change', t),
                            e.events.destroys.push(() => {
                                se.off('change', t);
                            });
                    } catch (e) {}
                    if (
                        (e.on(E.decoderWorkerInit, () => {
                            e.debug.log('player', 'has loaded'),
                                (e.loaded = !0);
                        }),
                        e.on(E.play, () => {
                            e.loading = !1;
                        }),
                        e.on(E.fullscreen, (t) => {
                            if (t)
                                try {
                                    se.request(e.$container)
                                        .then(() => {})
                                        .catch((t) => {
                                            e.webFullscreen = !0;
                                        });
                                } catch (t) {
                                    e.webFullscreen = !0;
                                }
                            else
                                try {
                                    se.exit()
                                        .then(() => {})
                                        .catch(() => {
                                            e.webFullscreen = !1;
                                        });
                                } catch (t) {
                                    e.webFullscreen = !1;
                                }
                        }),
                        e.on(E.webFullscreen, (t) => {
                            if (t) {
                                e.$container.classList.add(
                                    'webmediaplayer-fullscreen-web'
                                );
                                const { clientHeight: t, clientWidth: i } =
                                        document.body,
                                    { clientHeight: o, clientWidth: r } =
                                        e.video.$videoElement;
                                if (i / t < r / o) {
                                    const A = Math.min(t / r, i / o);
                                    e.video.$videoElement.style.transform = `rotate(90deg) scale(${A},${A})`;
                                }
                            } else
                                e.$container.classList.remove(
                                    'webmediaplayer-fullscreen-web'
                                ),
                                    (e.video.$videoElement.style.transform =
                                        null);
                        }),
                        e.on(E.resize, () => {
                            e.video.resize();
                        }),
                        e._opt.debug)
                    ) {
                        const t = [E.timeUpdate];
                        Object.keys(E).forEach((i) => {
                            e.on(E[i], (o) => {
                                t.includes(i) ||
                                    e.debug.log('player events', E[i], o);
                            });
                        }),
                            Object.keys(C).forEach((t) => {
                                e.on(C[t], (i) => {
                                    e.debug.log('player event error', C[t], i);
                                });
                            });
                    }
                })(this),
                ((e) => {
                    const {
                        _opt: t,
                        debug: i,
                        events: { proxy: o },
                    } = e;
                    t.supportDblclickFullscreen &&
                        o(e.$container, 'dblclick', () => {
                            e.fullscreen = !e.fullscreen;
                        }),
                        o(document, 'visibilitychange', () => {
                            t.hiddenAutoPause &&
                                (i.log(
                                    'visibilitychange',
                                    document.visibilityState,
                                    e._isPlayingBeforePageHidden
                                ),
                                'visible' === document.visibilityState
                                    ? e._isPlayingBeforePageHidden && e.play()
                                    : ((e._isPlayingBeforePageHidden =
                                          e.playing),
                                      e.playing && e.pause()));
                        }),
                        o(window, 'fullscreenchange', () => {
                            null !== e.keepScreenOn &&
                                'visible' === document.visibilityState &&
                                e.enableWakeLock();
                        });
                })(this),
                this._opt.useWCS && this.debug.log('Player', 'use WCS'),
                this._opt.useMSE && this.debug.log('Player', 'use MSE'),
                this._opt.useOffscreen &&
                    this.debug.log('Player', 'use offscreen'),
                this.debug.log('Player options', this._opt);
        }
        destroy() {
            (this._loading = !1),
                (this._playing = !1),
                (this._hasLoaded = !1),
                (this._times = {
                    playInitStart: '',
                    playStart: '',
                    streamStart: '',
                    streamResponse: '',
                    demuxStart: '',
                    decodeStart: '',
                    videoStart: '',
                    playTimestamp: '',
                    streamTimestamp: '',
                    streamResponseTimestamp: '',
                    demuxTimestamp: '',
                    decodeTimestamp: '',
                    videoTimestamp: '',
                    allTimestamp: '',
                }),
                this.decoderWorker &&
                    (this.decoderWorker.destroy(), (this.decoderWorker = null)),
                this.video && (this.video.destroy(), (this.video = null)),
                this.audio && (this.audio.destroy(), (this.audio = null)),
                this.stream && (this.stream.destroy(), (this.stream = null)),
                this.recorder &&
                    (this.recorder.destroy(), (this.recorder = null)),
                this.control && (this.control.destroy(), (this.control = null)),
                this.webcodecsDecoder &&
                    (this.webcodecsDecoder.destroy(),
                    (this.webcodecsDecoder = null)),
                this.mseDecoder &&
                    (this.mseDecoder.destroy(), (this.mseDecoder = null)),
                this.demux && (this.demux.destroy(), (this.demux = null)),
                this.events && (this.events.destroy(), (this.events = null)),
                this.clearCheckHeartTimeout(),
                this.clearCheckLoadingTimeout(),
                this.releaseWakeLock(),
                (this.keepScreenOn = null),
                this.resetStats(),
                (this._audioTimestamp = 0),
                (this._videoTimestamp = 0),
                this.emit('destroy'),
                this.off(),
                this.debug.log('play', 'destroy end');
        }
        set fullscreen(e) {
            this.emit(E.fullscreen, e);
        }
        get fullscreen() {
            return (
                document.isFullScreen ||
                document.mozIsFullScreen ||
                document.webkitIsFullScreen ||
                this.webFullscreen
            );
        }
        set webFullscreen(e) {
            this.emit(E.webFullscreen, e);
        }
        get webFullscreen() {
            return this.$container.classList.contains(
                'jessibuca-fullscreen-web'
            );
        }
        set loaded(e) {
            this._hasLoaded = e;
        }
        get loaded() {
            return this._hasLoaded;
        }
        set playing(e) {
            e && (this.loading = !1),
                this.playing !== e &&
                    ((this._playing = e),
                    this.emit(E.playing, e),
                    this.emit(E.volumechange, this.volume),
                    e ? this.emit(E.play) : this.emit(E.pause));
        }
        get playing() {
            return this._playing;
        }
        get volume() {
            return (this.audio && this.audio.volume) || 0;
        }
        set volume(e) {
            this.audio && this.audio.setVolume(e);
        }
        set loading(e) {
            this.loading !== e &&
                ((this._loading = e), this.emit(E.loading, this._loading));
        }
        get loading() {
            return this._loading;
        }
        set recording(e) {
            this.playing &&
                (e
                    ? this.recorder.startRecord()
                    : this.recorder.stopRecordAndSave());
        }
        get recording() {
            return this.recorder && this.recorder.recording;
        }
        set audioTimestamp(e) {
            null !== e && (this._audioTimestamp = e);
        }
        get audioTimestamp() {
            return this._audioTimestamp;
        }
        set videoTimestamp(e) {
            null !== e &&
                ((this._videoTimestamp = e),
                this._opt.useWCS ||
                    this._opt.useMSE ||
                    (this.audioTimestamp &&
                        this.videoTimestamp &&
                        this.audio &&
                        this.audio.emit(E.videoSyncAudio, {
                            audioTimestamp: this.audioTimestamp,
                            videoTimestamp: this.videoTimestamp,
                            diff: this.audioTimestamp - this.videoTimestamp,
                        })));
        }
        get videoTimestamp() {
            return this._videoTimestamp;
        }
        updateOption(e) {
            this._opt = Object.assign({}, this._opt, e);
        }
        init() {
            return new Promise((e, t) => {
                this.stream || (this.stream = new Ie(this)),
                    this.demux || (this.demux = new Oe(this)),
                    this._opt.useWCS &&
                        (this.webcodecsDecoder ||
                            (this.webcodecsDecoder = new Me(this))),
                    this._opt.useMSE &&
                        (this.mseDecoder || (this.mseDecoder = new He(this))),
                    this.decoderWorker || this._onlyMseOrWcsVideo()
                        ? e()
                        : ((this.decoderWorker = new je(this)),
                          this.once(E.decoderWorkerInit, () => {
                              e();
                          }));
            });
        }
        play(e) {
            return new Promise((t, i) => {
                if (!e && !this._opt.url) return i();
                (this.loading = !0),
                    (this.playing = !1),
                    (this._times.playInitStart = ce()),
                    e || (e = this._opt.url),
                    (this._opt.url = e),
                    this.clearCheckHeartTimeout(),
                    this.init()
                        .then(() => {
                            (this._times.playStart = ce()),
                                this._opt.isNotMute && this.mute(!1),
                                this.webcodecsDecoder &&
                                    this.webcodecsDecoder.once(
                                        C.webcodecsH265NotSupport,
                                        () => {
                                            this.emit(
                                                C.webcodecsH265NotSupport
                                            ),
                                                this._opt.autoWasm ||
                                                    this.emit(
                                                        E.error,
                                                        C.webcodecsH265NotSupport
                                                    );
                                        }
                                    ),
                                this.mseDecoder &&
                                    this.mseDecoder.once(
                                        C.mediaSourceH265NotSupport,
                                        () => {
                                            this.emit(
                                                C.mediaSourceH265NotSupport
                                            ),
                                                this._opt.autoWasm ||
                                                    this.emit(
                                                        E.error,
                                                        C.mediaSourceH265NotSupport
                                                    );
                                        }
                                    ),
                                this.enableWakeLock(),
                                this.stream.fetchStream(e),
                                this.checkLoadingTimeout(),
                                this.stream.once(C.fetchError, (e) => {
                                    i(e);
                                }),
                                this.stream.once(C.websocketError, (e) => {
                                    i(e);
                                }),
                                this.stream.once(E.streamSuccess, () => {
                                    t(),
                                        (this._times.streamResponse = ce()),
                                        this._opt.useMSE && this.video.play();
                                });
                        })
                        .catch((e) => {
                            i(e);
                        });
            });
        }
        close() {
            return new Promise((e, t) => {
                this._close().then(() => {
                    this.video.clearView(), e();
                });
            });
        }
        _close() {
            return new Promise((e, t) => {
                this.stream && (this.stream.destroy(), (this.stream = null)),
                    this.demux && (this.demux.destroy(), (this.demux = null)),
                    this.decoderWorker &&
                        (this.decoderWorker.destroy(),
                        (this.decoderWorker = null)),
                    this.webcodecsDecoder &&
                        (this.webcodecsDecoder.destroy(),
                        (this.webcodecsDecoder = null)),
                    this.mseDecoder &&
                        (this.mseDecoder.destroy(), (this.mseDecoder = null)),
                    this.clearCheckHeartTimeout(),
                    this.clearCheckLoadingTimeout(),
                    (this.playing = !1),
                    (this.loading = !1),
                    (this.recording = !1),
                    this.audio && this.audio.pause(),
                    this.releaseWakeLock(),
                    this.resetStats(),
                    (this._audioTimestamp = 0),
                    (this._videoTimestamp = 0),
                    (this._times = {
                        playInitStart: '',
                        playStart: '',
                        streamStart: '',
                        streamResponse: '',
                        demuxStart: '',
                        decodeStart: '',
                        videoStart: '',
                        playTimestamp: '',
                        streamTimestamp: '',
                        streamResponseTimestamp: '',
                        demuxTimestamp: '',
                        decodeTimestamp: '',
                        videoTimestamp: '',
                        allTimestamp: '',
                    }),
                    setTimeout(() => {
                        e();
                    }, 0);
            });
        }
        pause(e) {
            return e ? this.close() : this._close();
        }
        mute(e) {
            this.audio && this.audio.mute(e);
        }
        resize() {
            this.video.resize();
        }
        startRecord(e, t) {
            this.recording ||
                (this.recorder.setFileName(e, t), (this.recording = !0));
        }
        stopRecordAndSave() {
            this.recording && (this.recording = !1);
        }
        _hasControl() {
            let e = !1,
                t = !1;
            return (
                Object.keys(this._opt.operateBtns).forEach((e) => {
                    this._opt.operateBtns[e] && (t = !0);
                }),
                (this._opt.showBandwidth || this._opt.text || t) && (e = !0),
                e
            );
        }
        _onlyMseOrWcsVideo() {
            return (
                !1 === this._opt.hasAudio &&
                (this._opt.useMSE ||
                    (this._opt.useWCS && !this._opt.useOffscreen))
            );
        }
        checkHeart() {
            this.clearCheckHeartTimeout(), this.checkHeartTimeout();
        }
        checkHeartTimeout() {
            this._checkHeartTimeout = setTimeout(() => {
                this.pause(!1).then(() => {
                    this.emit(E.timeout, E.delayTimeout),
                        this.emit(E.delayTimeout);
                });
            }, 1e3 * this._opt.heartTimeout);
        }
        clearCheckHeartTimeout() {
            this._checkHeartTimeout &&
                (clearTimeout(this._checkHeartTimeout),
                (this._checkHeartTimeout = null));
        }
        checkLoadingTimeout() {
            this._checkLoadingTimeout = setTimeout(() => {
                this.pause(!1).then(() => {
                    this.emit(E.timeout, E.loadingTimeout),
                        this.emit(E.loadingTimeout);
                });
            }, 1e3 * this._opt.loadingTimeout);
        }
        clearCheckLoadingTimeout() {
            this._checkLoadingTimeout &&
                (clearTimeout(this._checkLoadingTimeout),
                (this._checkLoadingTimeout = null));
        }
        handleRender() {
            this.loading &&
                (this.emit(E.start),
                (this.loading = !1),
                this.clearCheckLoadingTimeout()),
                this.playing || (this.playing = !0),
                this.checkHeart();
        }
        updateStats(e) {
            (e = e || {}),
                this._startBpsTime || (this._startBpsTime = ce()),
                ye(e.ts) && (this._stats.ts = e.ts),
                ye(e.buf) && (this._stats.buf = e.buf),
                e.fps && (this._stats.fps += 1),
                e.abps && (this._stats.abps += e.abps),
                e.vbps && (this._stats.vbps += e.vbps);
            const t = ce();
            t - this._startBpsTime < 1e3 ||
                (this.emit(E.stats, this._stats),
                this.emit(
                    E.performance,
                    (function (e) {
                        let t = 0;
                        return e >= 24 ? (t = 2) : e >= 15 && (t = 1), t;
                    })(this._stats.fps)
                ),
                (this._stats.fps = 0),
                (this._stats.abps = 0),
                (this._stats.vbps = 0),
                (this._startBpsTime = t));
        }
        resetStats() {
            (this._startBpsTime = null),
                (this._stats = { buf: 0, fps: 0, abps: 0, vbps: 0, ts: 0 });
        }
        enableWakeLock() {
            this._opt.keepScreenOn && this.keepScreenOn.enable();
        }
        releaseWakeLock() {
            this._opt.keepScreenOn && this.keepScreenOn.disable();
        }
        handlePlayToRenderTimes() {
            const e = this._times;
            (e.playTimestamp = e.playStart - e.playInitStart),
                (e.streamTimestamp = e.streamStart - e.playStart),
                (e.streamResponseTimestamp = e.streamResponse - e.streamStart),
                (e.demuxTimestamp = e.demuxStart - e.streamResponse),
                (e.decodeTimestamp = e.decodeStart - e.demuxStart),
                (e.videoTimestamp = e.videoStart - e.decodeStart),
                (e.allTimestamp = e.videoStart - e.playInitStart),
                this.emit(E.playToRenderTimes, e);
        }
    }
    class _e extends ve {
        static ERROR = C;
        static TIMEOUT = {
            loadingTimeout: E.loadingTimeout,
            delayTimeout: E.delayTimeout,
        };
        constructor(e) {
            super();
            let t = e,
                i = e.container;
            if (
                ('string' == typeof e.container &&
                    (i = document.querySelector(e.container)),
                !i)
            )
                throw new Error('Jessibuca need container option');
            i.classList.add('jessibuca-container'),
                delete t.container,
                ye(t.videoBuffer) &&
                    (t.videoBuffer = 1e3 * Number(t.videoBuffer)),
                ye(t.timeout) &&
                    (be(t.loadingTimeout) && (t.loadingTimeout = t.timeout),
                    be(t.heartTimeout) && (t.heartTimeout = t.timeout)),
                (this._opt = t),
                (this.$container = i),
                (this.href = null),
                (this.events = new oe(this)),
                this._initPlayer(i, t);
        }
        destroy() {
            this.player.destroy(), (this.player = null), this.off();
        }
        _initPlayer(e, t) {
            (this.player = new Ke(e, t)), this._bindEvents();
        }
        _resetPlayer() {
            let e =
                arguments.length > 0 && void 0 !== arguments[0]
                    ? arguments[0]
                    : {};
            this.player.destroy(), (this.player = null);
            const t = Object.assign(this._opt, e);
            this._initPlayer(this.$container, t);
        }
        _bindEvents() {
            Object.keys(B).forEach((e) => {
                this.player.on(B[e], (t) => {
                    this.emit(e, t);
                });
            });
        }
        setDebug(e) {
            this.player.updateOption({ isDebug: !!e });
        }
        mute() {
            this.player.mute(!0);
        }
        cancelMute() {
            this.player.mute(!1);
        }
        setVolume(e) {
            this.player.volume = e;
        }
        audioResume() {
            this.player.audio && this.player.audio.audioEnabled(!0);
        }
        setTimeout(e) {
            (e = Number(e)),
                this.player.updateOption({
                    timeout: e,
                    loadingTimeout: e,
                    heartTimeout: e,
                });
        }
        setScaleMode(e) {
            let t = { isFullResize: !1, isResize: !1 };
            switch ((e = Number(e))) {
                case M:
                    (t.isFullResize = !1), (t.isResize = !1);
                    break;
                case Q:
                    (t.isFullResize = !1), (t.isResize = !0);
                    break;
                case W:
                    (t.isFullResize = !0), (t.isResize = !0);
            }
            this.player.updateOption(t), this.resize();
        }
        pause() {
            return this.player.pause();
        }
        close() {
            return (this._opt.url = ''), this.player.close();
        }
        clearView() {
            this.player.video.clearView();
        }
        play(e) {
            return new Promise((t, i) => {
                if (!e && !this._opt.url)
                    return this.emit(E.error, C.playError), void i();
                if (e) {
                    if (!this._opt.url) return this._play(e);
                    e === this._opt.url
                        ? this.player.playing
                            ? t()
                            : (this.clearView(),
                              this.player
                                  .play(this._opt.url)
                                  .then(() => {
                                      t();
                                  })
                                  .catch(() => {
                                      this.player.pause().then(() => {
                                          i();
                                      });
                                  }))
                        : this.player
                              .pause()
                              .then(() => (this.clearView(), this._play(e)))
                              .catch(() => {
                                  i();
                              });
                } else
                    this.player
                        .play(this._opt.url)
                        .then(() => {
                            t();
                        })
                        .catch(() => {
                            this.player.pause().then(() => {
                                i();
                            });
                        });
            });
        }
        _play(r) {
            return new Promise((A, s) => {
                this._opt.url = r;
                const n = 0 === r.indexOf('http'),
                    a = n ? t : e,
                    d =
                        n || -1 !== r.indexOf('.flv') || this._opt.isFlv
                            ? i
                            : o;
                this.player.updateOption({ protocol: a, demuxType: d }),
                    this.player.once(C.mediaSourceH265NotSupport, () => {
                        this.close().then(() => {
                            this.player._opt.autoWasm &&
                                (this.player.debug.log(
                                    'Jessibuca',
                                    'auto wasm [mse-> wasm] reset player and play'
                                ),
                                this._resetPlayer({ useMSE: !1 }),
                                this.play(r)
                                    .then(() => {
                                        this.player.debug.log(
                                            'Jessibuca',
                                            'auto wasm [mse-> wasm] reset player and play success'
                                        );
                                    })
                                    .catch(() => {
                                        this.player.debug.log(
                                            'Jessibuca',
                                            'auto wasm [mse-> wasm] reset player and play error'
                                        );
                                    }));
                        });
                    }),
                    this.player.once(C.webcodecsH265NotSupport, () => {
                        this.close().then(() => {
                            this.player._opt.autoWasm &&
                                (this.player.debug.log(
                                    'Jessibuca',
                                    'auto wasm [wcs-> wasm] reset player and play'
                                ),
                                this._resetPlayer({ useWCS: !1 }),
                                this.play(r)
                                    .then(() => {
                                        this.player.debug.log(
                                            'Jessibuca',
                                            'auto wasm [wcs-> wasm] reset player and play success'
                                        );
                                    })
                                    .catch(() => {
                                        this.player.debug.log(
                                            'Jessibuca',
                                            'auto wasm [wcs-> wasm] reset player and play error'
                                        );
                                    }));
                        });
                    }),
                    this.player.once(C.wasmDecodeError, () => {
                        this.player._opt.wasmDecodeErrorReplay &&
                            this.close().then(() => {
                                this.player.debug.log(
                                    'Jessibuca',
                                    'wasm decode error and reset player and play'
                                ),
                                    this._resetPlayer({ useWCS: !1 }),
                                    this.play(r)
                                        .then(() => {
                                            this.player.debug.log(
                                                'Jessibuca',
                                                'wasm decode error and reset player and play success'
                                            );
                                        })
                                        .catch(() => {
                                            this.player.debug.log(
                                                'Jessibuca',
                                                'wasm decode error and reset player and play error'
                                            );
                                        });
                            });
                    }),
                    this.player.once(E.delayTimeout, () => {
                        this.player._opt.heartTimeoutReplay &&
                            this.play(r)
                                .then(() => {})
                                .catch(() => {});
                    }),
                    this.hasLoaded()
                        ? this.player
                              .play(r)
                              .then(() => {
                                  A();
                              })
                              .catch(() => {
                                  this.player.pause().then(() => {
                                      s();
                                  });
                              })
                        : this.player.once(E.decoderWorkerInit, () => {
                              this.player
                                  .play(r)
                                  .then(() => {
                                      A();
                                  })
                                  .catch(() => {
                                      this.player.pause().then(() => {
                                          s();
                                      });
                                  });
                          });
            });
        }
        resize() {
            this.player.resize();
        }
        setBufferTime(e) {
            (e = Number(e)),
                this.player.updateOption({ videoBuffer: 1e3 * e }),
                this.player.decoderWorker &&
                    this.player.decoderWorker.updateWorkConfig({
                        key: 'videoBuffer',
                        value: 1e3 * e,
                    });
        }
        setRotate(e) {
            e = parseInt(e, 10);
            this._opt.rotate !== e &&
                -1 !== [0, 90, 270].indexOf(e) &&
                (this.player.updateOption({ rotate: e }), this.resize());
        }
        hasLoaded() {
            return this.player.loaded;
        }
        setKeepScreenOn() {
            this.player.updateOption({ keepScreenOn: !0 });
        }
        setFullscreen(e) {
            const t = !!e;
            this.player.fullscreen !== t && (this.player.fullscreen = t);
        }
        screenshot(e, t, i, o) {
            return this.player.video.screenshot(e, t, i, o);
        }
        startRecord(e, t) {
            return new Promise((i, o) => {
                this.player.playing
                    ? (this.player.startRecord(e, t), i())
                    : o();
            });
        }
        stopRecordAndSave() {
            this.player.recording && this.player.stopRecordAndSave();
        }
        isPlaying() {
            return this.player.playing;
        }
        isMute() {
            return !this.player.audio || this.player.audio.isMute;
        }
        isRecording() {
            return this.player.recorder.recording;
        }
    }
    return (window.Jessibuca = _e), _e;
});
